Kaseya Community

Citrix and Temrinal Server Licensing

  • I'm trying to monitor terminal server and Citrix licensing so that we can be sure clients won't be denied logon due to insufficient licenses.

    I have tried setting up Event Sets to watch the eventlog (for events 21 and 41 for TS and events 19 and 9017 for Citrix) but I am not sure if this will actually capture things in time.

    Has anyone else attempted this? If so, what was your approach?

    Legacy Forum Name: Citrix and Temrinal Server Licensing,
    Legacy Posted By Username: Maclean
  • This is a little late but in case anyone else is interested. I use the vbscript below. I found the bulk of it online and tweaked it to pipe the license count to a text file and run a follow up script to query the output and email updates to support.
    I'm sure someone out there will be able to clean the script up to run a little better but it gets the job done.
    '----------------------------------------------------------------------------------------------------------------------------
    ' Script : CitrixLicCount.vbs
    ' Description : Check Licenses in use
    ' Author : Super Pippo
    ' Date : 7.10.2005
    ' Revision :
    ' Argument : none
    '----------------------------------------------------------------------------------------------------------------------------

    smtpServer = "email server"
    sFrom = "from email"
    sSL = "Citrix Licensing Warning"
    sCSL = "Critical Citrix Licensing Warning"
    Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
    Const cdoSendUsingPort = 2 '//This is for network, for a localhost smtp server use 1
    Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
    Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
    Public countLicenses
    CriticalLimit = 83 'choose the limit that triggers the critical alarm
    WarningLimit = 70 'choose the limit that triggers the warning alarm

    CheckMPSLicUsage

    Function CheckMPSLicUsage
    CommandLine = "c:\program files\citrix\licensing\ls\lmstat -a"
    Set objShell = CreateObject("WScript.Shell")
    Set oExec = objShell.Exec(CommandLine)
    countLicenses = 0

    Do Until oExec.StdOut.AtEndOfStream
    Input = oExec.StdOut.ReadLine
    if InStr(Input, "v2005.0427") Then
    countLicenses = countLicenses + 1
    end if
    Loop

    End Function

    If countLicenses > CriticalLimit Then

    sRecipients = "support email address"
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields
    strFileName = "C:\temp\CitrixLicenseCount.txt"
    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)
    objTextStream.WriteLine "Critical: Citrix License Count is " & countLicenses

    With Flds
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServer) = smtpServer
    .Update
    End With

    With iMsg
    Set .Configuration = iConf
    .To = sRecipients
    .CC = sCopy
    .From = sFrom
    .Sender = sSender
    .Subject = sCSL
    .TextBody = "Critical: Citrix Licensing server is using " & countLicenses & " licenses. Critical limit is: " & CriticalLimit
    .Send
    End With
    Set iMsg = Nothing
    Set iConf = Nothing

    Elseif countLicenses WarningLimit Then
    sRecipients = "support email address"
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields
    strFileName = "C:\temp\CitrixLicenseCount.txt"
    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objTextStream = objFSO.OpenTextFile(strFileName, 2, True)
    objTextStream.WriteLine "Warning: Citrix License Count is " & countLicenses


    With Flds
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServer) = smtpServer
    .Update
    End With

    With iMsg
    Set .Configuration = iConf
    .To = sRecipients
    .CC = sCopy
    .From = sFrom
    .Sender = sSender
    .Subject = sSL
    .TextBody = "Citrix Licensing server is using " & countLicenses & " licenses. Critical limit is: " & CriticalLimit
    .Send
    End With

    Set iMsg = Nothing
    Set iConf = Nothing


    End if


    Legacy Forum Name: Event Sets,
    Legacy Posted By Username: neteffect