Trying to set up monitor to show real time license use on our Citrix license server. I used a template from PRTGPlugins, but it doesn't list the licenses. Only shows RDP and Ping monitors.


Article Comments

Hello,

I'm afraid that might only be possible with Custom EXE-Sensors, but of course you could also contact the developer of PRTGPlugins.

best regards.


Dec, 2011 - Permalink

I have a custom WMI sensor setup that was monitoring license use fine, until I renewed my Citrix Licenses and restarted the license server. Now the sensor fails with "Query returned more than one record error: PE078". I have uninstalled the license server and re installed and also deleted and recreated the sensor. Still no luck getting the sensor to work again.


May, 2012 - Permalink

As the sensor mentions, it seems more than one result is returned, and you need to adjust the query as it needs to be only one. You can use the WMI Tester to help with the testing.


May, 2012 - Permalink

Looks like it does indeed return two records, one looks bogus as it lists 0 in the in use count. They both look identical except for the fact one returns 0 in the in use count. Any idea how to get to read only the correct one?


May, 2012 - Permalink

Sorry, no. How would we know that?


May, 2012 - Permalink

Apparently that record is supposed to be there. I see it on all our license servers. So I'm back to the original problem of getting the "Query returned more than one record error: PE078" when running the custom WMI sensor with a WQL statement of "SELECT InUseCount FROM CITRIX_GT_LICENSE_POOL". Is there a way to get it to total the two records and present that to PRTG? I installed the PRTG Plugins, but it didn't have a template for Citrix Licensing. They have zero support and I haven't been able to get in touch with anyone from there to figure out why it doesn't work.


May, 2012 - Permalink

You could try expanding the query with something like

... Where Name ="_Total"

Or if this does not help, do this with a vb-script which calculates the total itself.


May, 2012 - Permalink

Unfortunately with Citrix licensing you need to enumerate them all to get the full license count and usage since all licenses are individually in WMI. This is why we made the plugin.


Aug, 2012 - Permalink

I've been beating this horse on and off for a couple days. Here is my powershell script. No promises. It gets the total licenses, the amount in use, computes a percentage, and returns a value. Just copy and paste it the Powershell ISE on your sensor server and try it. You will need to adjust the server...it's all in the comments.

# Setup Variables
$Total = 0
$InUse = 0
$PercentUsed = 0
$Retstring = 0
$RetValue = 0

# Get Citrix licensing Info
# Use the IP address of the License server(-comp switch).  I got inconsistent results using the hostname
$licensePool = gwmi -class "Citrix_GT_License_Pool" -Namespace "ROOT\CitrixLicensing" -comp 172.16.10.14

# This will display all the license info....Uncomment for troubleshooting
# $licensePool | Select-Object @{n="Product";e={$_.PLD}},
#                            @{n="Installed";e={$_.Count}},
#                            @{n="In Use";e={$_.InUseCount}},
#                            @{n="Available";e={$_.PooledAvailable}},
#                            @{n="% in use";e={($_.InUseCount/$_.Count)*100}}
                            
# This loops through all the license info and adds up the total license count and in use count for MPS_ENT_CCU licenses
# If you do not have MPS_ENT_CCU licenses, uncomment the section above and look at the output.  Figure out your license count from that.  Edit Script as needed                            
$LicensePool | ForEach-Object{ If ($_.PLD -eq "MPS_ENT_CCU"){
    $Total = $Total + $_.count
    $InUse = $InUse + $_.InUseCount
    }
}

#  Uncomment to confirm values are correct    
# "Total = ", $Total
# "In Use = ", $Inuse

$PercentUsed = [Math]::Round($inuse/$total*100,0)

#  Determine return code.  Less than 90%, ok, 90-97 Warning, 98-100 Error
switch ($PercentUsed)
    {
        {$PercentUsed -lt 90} {
            $RetString = "0:OK"	
            $RetVal = 0
            break
            }
        {$PercentUsed -ge 90 -and $PercentUsed -lt 98} {
            $RetString = "1:Warning 90-97% License Usage"	
            $RetVal = 1
            break
            }
        {$PercentUsed -ge 98} {
            $RetString = "2:ALERT 98-100% License Usage"	
            $RetVal = 2
            }
}

# Return Info
Write-Host $RetString
exit $RetVal

Jan, 2013 - Permalink

It was requested that we keep track of the actual number of licenses used. I changed the switch statement to return that value instead of 0, 1, or 2. So your graph will now reflect the actual number of licenses used.

switch ($PercentUsed)
    {
        {$PercentUsed -lt 90} {
            $RetString = [string]$Inuse+":OK"	
            $RetVal = 0
            break
            }
        {$PercentUsed -ge 90 -and $PercentUsed -lt 98} {
            $RetString = [string]$Inuse+":Warning 90-97% License Usage"	
            $RetVal = 1
            break
            }
        {$PercentUsed -ge 98} {
            $RetString = [string]$Inuse+":ALERT 98-100% License Usage"	
            $RetVal = 2
            }
}

Jan, 2013 - Permalink

hello, i have added your script to my exe folder and added a custom sensor. but it display me 0 # . when i run the powershell script on the prtg server it shows me the correct entry like 100 licenses are active.

can you please help me adding the custom sensor and its settings?

kind regards,

sebastian


Feb, 2017 - Permalink

Gret Job, but i get this error:

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Citrix_LIC03.ps1 Get-WmiObject : Zugriff verweigert (Ausnahme von HRESULT: 0x80070005 (E_ACCESSDENIED)) Bei C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Citrix_LIC03.ps1:16 Zeichen:20 + $licensePool = gwmi <<<< -class "Citrix_GT_License_Pool" -Namespace "ROOT\CitrixLicensing" -comp $server + CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Es wurde versucht, durch 0 (null) zu teilen. Bei C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\Citrix_LIC03.ps1:37 Zeichen:37 + $PercentUsed = [Math]::Round($inuse/ <<<< $total*100,0) + CategoryInfo : NotSpecified: (:) [], RuntimeException + FullyQualifiedErrorId : RuntimeException

Can you help me?


Jul, 2017 - Permalink

I have made a xml sensor out of this. Additionally I have made the target computer variable via a script parameter (host%)



param([string]$computername = "")

# Setup Variables
$Total = 0
$InUse = 0
$Available = 0
$PercentUsed = 0
$Retstring = 0
$RetValue = 0

# Get Citrix licensing Info
# Use the IP address of the License server(-comp switch).  I got inconsistent results using the hostname
$licensePool = gwmi -class "Citrix_GT_License_Pool" -Namespace "ROOT\CitrixLicensing" -comp $computername

# This will display all the license info....Uncomment for troubleshooting
# $licensePool | Select-Object @{n="Product";e={$_.PLD}},
#                            @{n="Installed";e={$_.Count}},
#                            @{n="In Use";e={$_.InUseCount}},
#                            @{n="Available";e={$_.PooledAvailable}},
#                            @{n="% in use";e={($_.InUseCount/$_.Count)*100}}
                            
# This loops through all the license info and adds up the total license count and in use count for MPS_ENT_CCU licenses
# If you do not have MPS_ENT_CCU licenses, uncomment the section above and look at the output.  Figure out your license count from that.  Edit Script as needed                            
#$LicensePool | ForEach-Object{ If ($_.PLD -eq "MPS_ENT_CCU"){
$LicensePool | ForEach-Object{ If ($_.PLD -eq "XDT_ENT_UD"){
    $Total = $Total + $_.count
    $InUse = $InUse + $_.InUseCount
    $Available = $Available + $_.PooledAvailable
    }
}

#  Uncomment to confirm values are correct    
# "Total = ", $Total
# "In Use = ", $Inuse

$PercentUsed = [Math]::Round($inuse/$total*100,0)


#Write Results
write-host "<prtg>"
 
Write-Host "<result>"
Write-Host "<channel>Total</channel>"
Write-Host "<value>$($Total)</value>"
Write-Host "</result>"
 
Write-Host "<result>"
Write-Host "<channel>In use</channel>"
Write-Host "<value>$($Inuse)</value>"
Write-Host "</result>"

Write-Host "<result>"
Write-Host "<channel>Available</channel>"
Write-Host "<value>$($Available)</value>"
Write-Host "</result>"
 
Write-Host "<result>"
Write-Host "<channel>Use Percentage</channel>"
Write-Host "<value>$($PercentUsed)</value>"
Write-Host "</result>"
 
write-host "</prtg>"


May, 2020 - Permalink

Hi, do you have more Information how to create the xml sensor for this?

kind regards,

sebastian


Mar, 2023 - Permalink