
Monitoring Citrix profiles with Centreon and Grafana
We will use this document to monitor with Centreon the size and number of files that our Citrix roaming profiles have, Of course, we can use it to monitor other folders.
In principle, we will rely on a PowerShell script that we will normally execute from the server, which is the one that stores the profiles. This script will read all the content of the directory that we indicate and will take a summary for each user, your number of files, and what occupies your folder or profile. In addition, the script is fully prepared and the output will do it correctly to have metrics for each user. As usual, we will execute this remotely with NRPE, So if you still don't know how it works or how to install it, Take a look at This post old man.
If we download the following PowerShell script and modify the line 15, which is the path of the folder to be analyzed, we have it ready to test!
# Variable vacuum, yo que se pq.. :) $Objetos = "" $Tamano = "" $Profile = "" $TotalObjects = "" $SizeMB = "" $lines = "" $line = "" $Todos = "" $Files = "" $Size = "" # Exporta a CSV las carpetas con su tamaño y total de objetos (Get-Culture).NumberFormat.NumberDecimalSeparator = '.' Get-ChildItem -path "F:\PerfilesCitrixUPM*" | Foreach { $Files = Get-ChildItem $_. FullName -Recurse| Where-Object { -not $_. PSIsContainer } -ErrorAction SilentlyContinue $Size = (( $Files | Measure-Object -Property Length -Sum).Sum /1MB) $Size = [math]::round($Size,2) [PSCustomObject]@{Profile = $_. Name ; TotalObjects = "$($Files.Count)" ; SizeMB = $Size} } | Export-CSV "perfiles-size.csv" -NoTypeInformation # Formatea estilo Nagios $lines = Get-Content .perfiles-size.csv | Select -skip 1 | ConvertFrom-Csv -Header Profile,TotalObjects,SizeMB ForEach ($line in $lines){ $Profile = $($line. Profile) $TotalObjects = $($line. TotalObjects) -as [int] $SizeMB = $($line. SizeMB) -as [int] $Todos =$Profile.replace(' ','') + "_tamano=" + $SizeMB + " " + $Profile.replace(' ','') + "_ficheros=" + $TotalObjects + " " + $Todos # Más de 1000 objetos If ($TotalObjects -gt 1000){ $Objects = $Profile.replace(' ','') + ", " + $Objects } # More than 100Mb (100) If ($SizeMB -gt 200){ $Size = $Profile.replace(' ','') + ", " + $Size } } If ($Objects.length -gt 0 -And $Tamano.length -gt 0){ Write-Host "CRITICAL - Many files in" $Objects + "Large profile in" $Size"|"$All exit 2 } ElseIf ($Objects.length -gt 0){ Write-Host "CRITICAL - Many files in" $Objects"|"$All exit 2 } ElseIf ($Size.length -gt 0){ Write-Host "CRITICAL - Large profile in" $Size"|"$All exit 2 } Else { Write-Host "OK - Profiles correctly |"$All exit 0 }
And now we register as we already know, in the file nsclient.ini the configuration needed to execute that script from the Centreon machine, The only thing to keep in mind, if you have a lot of files and it takes a long time to make the query, We can increase the timeout or the number of characters if necessary, Something like this would serve us well:
[/settings/NRPE/server] timeout = 120 Payload length = 15000 [/settings/external scripts] timeout = 120 [/settings/external scripts/scripts] check_perfiles = cmd /c echo scripts\Tamano_Perfiles_UPM.ps1; exit($lastexitcode) | powershell.exe -command -
And if that were our case, when creating the service in Centreon after passing the argument 'check_perfiles’ which we indicate in the nsclient.ini, We can accompany you with ‘ -P 15000 -t 120’ as extra arguments, This is, if we need to expand the number of characters or the timeout to something specific, Like 'ñapa’ for not touching the Command.
And that's it! After exporting the configuration we will have the pack of Citrix UPM profiles under control or if we use another type of mobile profile, or if we want to monitor any other folder to see its size, o Number of files.
And nothing, To remember, Even if this graph is super nasty, But it was to give an idea, that you can integrate it with Grafana, which is very simple, If you want to know how to set it up, Remember This other document.
I hope it has been useful, Greetings to tod@s!