Monitoring Citrix Licenses with Centreon

If we want to have centralized control of the licenses of our Citrix environments, we can easily do it with Centreon, as usual, we will base ourselves on a script that will run on the license server and pass its output to Centreon, this way we will know when we are going to run out of licenses and above all, we will have them under control and they will serve to justify new acquisitions.

 

As you can imagine, we'll use NRPE to be able to call a script from Centreon, running on the Windows server, and let's read its output to know the licenses we currently have consumed and if necessary receive an alert. If you need to take a look at the functioning of NRPE, I recommend you read first This post, since we rely on it for the configurations we need to apply now in order to control the licenses.

On the Citrix License Server, after installing NSClient++, in the scripts directory, We'll put this one “licencias_citrix.cmd”:

 

[SourceCode]@echo off
"%ProgramFiles(x86)%\CitrixLicensingLSLMSTAT.exe" -a -c "%ProgramFiles(x86)%\CitrixLicensingMyFiles" > licencias.txt

FINDSTR "MPS_ADV_CCU:" licencias.txt > licencias2.txt
Set /p line= <licencias2.txt
set licenses=%linea:~63.2%
if %licenses%gtr 120 if %licenses%lss 131 (
echo "Warning – There are %licenses% consumed |'Citrix Licenses' =%licenses%"
exit /B 1
)
if %licenses%gtr 130 (
echo "Critical – There are %licenses% consumed |'Citrix Licenses' =%licenses%"
exit /B 2
)
if %licenses%lss 121 (
echo "OK – There are %licenses% consumed |'Citrix Licenses' =%licenses%"
exit /B 0
)[/SourceCode]

 

As we can see, this Batch script if we run it will query LMSTAT.exe, it will generate a temporary file with all the output and we will read the lines where we have defined our licenses, in this case some “XDT_ENT_UD” o XenDesktop Enterprise, I'm sure something fancier would work too, But wow, It should go well, or modify it based on your need. As we can see here, we directly indicate the values of licenses consumed, if there are more than 120 that generates a Warning and if there are more than 130 consumed therefore a Critical message.

 

In nsclient.ini we must as always define an Alias and the Command that will call this Alias, so that check_nrpe can call this Alias, it would be as follows:

 

[SourceCode][/settings/external scripts/scripts]
check_citrix_lics = cmd /c scripts\licencias_citrix.cmd

[/settings/external scripts/alias]
check_citrix_lics = check_citrix_lics[/SourceCode]

 

And as always, after saving the file remember to restart the NSClient++ service to reload the configuration.

 

We will now be able to create our Service associated with the License Server at Centreon, in the command we use the “check_nrpe” that we will have already defined (Remember This post If you need it). And as an argument, we pass on the alias that we have defined in the nsclient.ini to execute the BAT (The script).

 

As usual, after saving the configuration and exporting the Centreon files, We will be able to verify how we have the service ready and monitored! That's how easy it is to get something else out of our heads! We have controlled the licenses, in the face of the need and running out of them we will know it beforehand and we will be able to act accordingly. I hope you found it interesting,

 

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!