Using PowerShell and check_mk to monitor Citrix Licensing Usage

24. January 2017

blog.feldmann.io

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)"
    }
#check_mk #PowerShell
2 Comments
Marcus
24. November 2017 @ 10:34

hello,

i tested this powershell script and `have a question:
<<>>
0 CitrixLicensing used_licenses=6 38 percent of licenses in use (6 from 16)
<<>>
2 CitrixLicensing used_licenses=11 100 percent of licenses in use(11 from 11)

we have 25 licenses….

Reply
    Sebastian
    24. November 2017 @ 11:26

    Can you try the latest version and let me know the result?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *


*