Using PowerShell and check_mk to monitor Citrix Licensing Usage
24. January 2017
PowerShell Version: >4
Modules: none
I just wrote a custom local check for check_mk to get the Citrix Licensing Usage checked. All you need to do is fill in the $license_server and maybe customize $percent_warning and $percent_critical. The check reads the licensing WMI and gives you OK / WARNING / CRIT in check_mk for the corresponding variables. It will also show the actual used licenses as performance data:
# reset arrays $inusecount = @() $count = @() # globals $license_server = "YOUR_LICENSE_SERVER" $percent_warning = "90" $percent_critical = "95" # script $citrix_licenses = Get-WmiObject -class “Citrix_GT_License_Pool” -namespace “ROOT\CitrixLicensing” -ComputerName $license_server| select Count, InUseCount foreach ($citrix_license in $citrix_licenses) { if ($($citrix_license.inusecount) -ne "0") { $inusecount += $($citrix_license.inusecount) $count += $($citrix_license.Count) } } # summing up variables for multiple licenses $inusecount_sum = $(($inusecount | Measure-Object -Sum).Sum) $count_sum = $(($count | Measure-Object -Sum).Sum) # calculation and echo $PercentageNum = [math]::round(($inusecount_sum/$count_sum)*100,0) if ($PercentageNum -lt $percent_warning) { echo `<`<`<local`>`>`> echo "0 CitrixLicensing used_licenses=$inusecount_sum $PercentageNum percent of licenses in use ($inusecount_sum of $count_sum)" } elseif ($PercentageNum -gt $percent_critical) { echo `<`<`<local`>`>`> echo "2 CitrixLicensing used_licenses=$inusecount_sum $PercentageNum percent of licenses in use ($inusecount_sum of $count_sum)" } else { echo `<`<`<local`>`>`> echo "1 CitrixLicensing used_licenses=$inusecount_sum $PercentageNum percent of licenses in use ($inusecount_sum of $count_sum)" }