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

3 comments:

  1. Trev, did you ever post how to import this script into nsclient++?

    ReplyDelete
  2. Errrm, no

    I really should though. Check back in a day or so and I'll put it up.

    Thanks

    ReplyDelete
  3. Gambling Hall - New York, NY - MapyRO
    Located just outside of Syracuse, Gambling Hall is home to a wide variety of table games 김제 출장안마 including 경주 출장안마 blackjack, roulette, craps, and 부천 출장마사지 craps. Find your next event at  거제 출장안마 Rating: 군포 출장샵 4.6 · ‎75 votes

    ReplyDelete