Showing posts with label monitoring. Show all posts
Showing posts with label monitoring. Show all posts

Wednesday, 7 September 2011

Monitoring Citrix Xenapp licenses through Nagios

Hi all,

More scripts. Again in VBS. This time for monitoring citrix licensing.

All this script does is check to see how many licenses are being used as a percentage of the total. Then returns normal, warning or critical depending on %age.



' change this line to suit the location of the lmstat utility
' ***
CommandLine = "C:\Program Files\Citrix\Licensing\LS\lmstat -c ""C:\Program Files\Citrix\Licensing\MyFiles\license_file.lic"" -f MPS_ADV_CCU"
' ***

Set objShell = CreateObject("WScript.Shell")
Set oExec = objShell.Exec(CommandLine)
countLicenses = 0

Do Until oExec.StdOut.AtEndOfStream
mystring= oExec.StdOut.ReadLine
if InStr(mystring, "Users of MPS_ADV_CCU:") Then

issued_start = InStr(mystring,"(Total of ")
issued_len = InStr(mystring, " licenses issued;") - (issued_start + 10)

lic_total = Mid(mystring, issued_start + 10, issued_len)

'-------------------------------------------------------------------------------------------------------------------------------------------------
inuse_start = InStr(mystring,"; Total of ")
inuse_len = InStr(mystring, " licenses in use)") - (inuse_start + 12)


lic_inuse = Mid(mystring, inuse_start + 12, inuse_len)


pc = int(lic_inuse / lic_total * 100)
'pc = 93

if pc => 90 then


WScript.Echo "Critical - " & pc & "% in use"
WScript.Quit(2)
end if


if pc => 80 then


WScript.Echo "Warning - " & pc & "% in use"
WScript.Quit(1)
else

WScript.Echo "OK - " & pc & "% in use"
WScript.Quit(0)
end if


Exit Do

end if
Loop
There you have it. Normal restrictions apply. If you run it and it breaks your stuff, its your fault for running untested code. It works for me.

Import this script into nsclient++ and nagios in the normal way. I will document this at some point.

Thanks for reading.

Trev