Have you ever wandered how Citrix License usage looks like? You can open License Server console and check it. But what about some graphs or proactive informations? You can use EdgeSight – there is License Server monitoring tool. But what can you do, if you don’t want to install this tool. EdgeSigth is dedicated to old XenApp – based on IMA – and is no longer supported. So it rather pointless to use it. Mayby we can export informations from server and create graphs in Excel. Or, if we want to have “online” monitoring, we can use greate tool called – RRDtool. Information from official website:
What RRDtool does
RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. RRDtool can be easily integrated in shell scripts, perl, python, ruby, lua or tcl applications.
So I decided to write simple mechanism to create nice usage graphs:
We will use:
- PowerShell and CMD – to write all scripts
- WMI – to get information from Citrix License Server
- RRDtool – to save data in Round Robin Database and to generate nice graphs
All script will be executed on Citrix License Server. You can modify update script to call WMI remotly.
Create new directory called CTX. Inside this directory we will have:
- graphs – folder contain generated graphs
- RRDtool – windows binaries
- CtxLicUsage.rrd – our Round Robin Database
- CtxLicUsage_Graph.bat – script with commands to generate graphs – this batch is run using Task Scheduler
- CtxLicUsage_Update.bat – script to execute PowerShell script- CtxLicUsage_Update.ps1 – this batch is run using Task Scheduler (every 5 minutes)
- CtxLicUsage_Update.ps1 – script to update RRD file
So let’s start. At the beginning let’s create new RRD file – we will do this only once:
c:\CTX\RRDtool\rrdtool.exe create CtxLicUsage.rrd \ --start now-10m --step 300 \ DS:total:GAUGE:450:0:U \ DS:used:GAUGE:450:0:U \ DS:avail:GAUGE:450:0:U \ DS:overdraft:GAUGE:450:0:U \ RRA:AVERAGE:0.5:1:2880 \ RRA:AVERAGE:0.5:3:2880 \ RRA:AVERAGE:0.5:9:2880 \ RRA:AVERAGE:0.5:54:2880
We created one RRD file with 4 Data Sources (DS). These DS will collect informations about license usage – total, used, available and overdraft (these overdraft exists only in User/Device license type, so if you want to monitor CCU type you can make simple modifications). We will be collecting data every 300 seconds (5 minutes) – I think it’s enough for U/D licenses, but you can change it to 1 minute (for CCU). We will collect all data in 4 Round Robin Archives (RRA). 1st for 10 days (2880 samples every 300 seconds is 864000 seconds / 60 seconds = 14400 hours / 60 minutes = 240 hours / 24 hour = 10 days), 2nd for 30 days, 3rd for 3 months and the last one for 18 months.
CtxLicUsage_Update.ps1
$licensePool = gwmi -class "Citrix_GT_License_Pool" -Namespace "ROOT\CitrixLicensing" $usage = $licensePool | where-object {$_.PLD -like "XDT_ENT_UD"} | select Count,InUseCount,PooledAvailable,Overdraft # Write-Host $usage.Count $usage.InUseCount $usage.PooledAvailable $unixtime = [int][double]::Parse($(Get-date -date (Get-Date).ToUniversalTime()-uformat %s)) $cmd = "C:\CTX\RRDtool\rrdtool.exe update CtxLicUsage.rrd $($unixtime):$($usage.Count):$($usage.InUseCount):$($usage.PooledAvailable):$($usage.Overdraft)" iex $cmd
What we do in this script. We are using WMI to get information about licenses. Then we are creating update command. Remember, rrdtool update accept only unix timestamps, and command syntax is:
rrdtool.exe update database.rrd unix_timestamp:value1:value2:value3:value4
So in my case it was:
rrdtool.exe update CtxLicUsage.rrd 1429608601:660:537:123:60 rrdtool.exe update CtxLicUsage.rrd 1429608901:660:537:123:60 rrdtool.exe update CtxLicUsage.rrd 1429609201:660:537:123:60 rrdtool.exe update CtxLicUsage.rrd 1429609501:660:537:123:60 rrdtool.exe update CtxLicUsage.rrd 1429611301:660:538:122:60 rrdtool.exe update CtxLicUsage.rrd 1429611601:660:539:121:60 rrdtool.exe update CtxLicUsage.rrd 1429611901:660:540:120:60 rrdtool.exe update CtxLicUsage.rrd 1429612201:660:541:119:60 rrdtool.exe update CtxLicUsage.rrd 1429612501:660:540:120:60
OK, updating PowerShell script is done. Now we have to execute it every 5 minutes. So let’s use Windows Task Scheduler for this. Create file CtxLicUsage_Update.bat:
PowerShell.exe -command ". C:\CTX\CtxLicUsage_Update.ps1" C:\CTX\CtxLicUsage_Graph.bat
We will call PoSH update commands and after that we will generate graphs. Now set Task Scheduler, to execute this CtxLicUsage_Update.bat script every 5 minutes (infinitely). So right now our RRD database will be filled with data every 300 seconds.
The last and most spectacular step – graph generating.
CtxLicUsage_Graph.bat
c:\CTX\RRDtool\rrdtool.exe graph graphs\CtxLicUsage-1d.png -w 600 -h 200 --slope-mode \ --vertical-label "Licenses Checked Out" --title "Citrix license usage - XDT_ENT_UD - User/Device" \ DEF:Total=CtxLicUsage.rrd:total:AVERAGE \ DEF:Used=CtxLicUsage.rrd:used:AVERAGE \ DEF:Avail=CtxLicUsage.rrd:avail:AVERAGE \ DEF:Overdraft=CtxLicUsage.rrd:overdraft:AVERAGE \ CDEF:LineUsed=Used,1,* \ CDEF:LineAvail=Avail,1,* \ CDEF:LineTotal=Total,1,* \ CDEF:LineOverdraft=Total,Overdraft,- \ COMMENT:" " COMMENT:"Last " COMMENT:"Maximum " COMMENT:"Average " COMMENT:"Minimum\l" \ AREA:LineUsed#fe3562:"Used ":STACK GPRINT:Used:LAST:"%%6.3lf %%S" GPRINT:Used:MAX:"%%6.3lf %%S" GPRINT:Used:AVERAGE:"%%6.3lf %%S" GPRINT:Used:MIN:"%%6.3lf %%S\l" \ AREA:LineAvail#cfe694:"Available ":STACK GPRINT:Avail:LAST:"%%6.3lf %%S" GPRINT:Avail:MAX:"%%6.3lf %%S" GPRINT:Avail:AVERAGE:"%%6.3lf %%S" GPRINT:Avail:MIN:"%%6.3lf %%S\l" \ LINE2:LineTotal#3b73fc:"Total " GPRINT:Total:LAST:"%%6.3lf %%S" GPRINT:Total:MAX:"%%6.3lf %%S" GPRINT:Total:AVERAGE:"%%6.3lf %%S" GPRINT:Total:MIN:"%%6.3lf %%S\l" \ LINE1:LineOverdraft#9e0b0f:"Overdraft " GPRINT:Overdraft:LAST:"%%6.3lf %%S" GPRINT:Overdraft:MAX:"%%6.3lf %%S" GPRINT:Overdraft:AVERAGE:"%%6.3lf %%S" GPRINT:Overdraft:MIN:"%%6.3lf %%S\l"
By default graph command generate image for 1 day time period. First graph (at the beginning of this post) was generated using this command. If you want to create image for 10 days period you can add
--end now --start end-10d
so the first line will be:
c:\CTX\RRDtool\rrdtool.exe graph graphs\CtxLicUsage-10d.png -w 600 -h 200 –end now –start end-10d –slope-mode
At the beginning I wrote, that we can do some predictions. Let’s generate trend line (we will show 10 days prediction using 10 days data from the past):
c:\CTX\RRDtool\rrdtool.exe graph graphs\CtxLicUsage-trend.png -w 600 -h 200 --end now+10d --start now-10d --slope-mode \ --vertical-label "Licenses Checked Out" --title "Citrix license usage - XDT_ENT_UD - User/Device" \ DEF:Total=CtxLicUsage.rrd:total:AVERAGE \ DEF:Used=CtxLicUsage.rrd:used:AVERAGE \ DEF:Avail=CtxLicUsage.rrd:avail:AVERAGE \ DEF:Overdraft=CtxLicUsage.rrd:overdraft:AVERAGE \ CDEF:LineUsed=Used,1,* \ CDEF:LineAvail=Avail,1,* \ CDEF:LineTotal=Total,1,* \ CDEF:LineOverdraft=Total,Overdraft,- \ VDEF:slope=LineUsed,LSLSLOPE \ VDEF:cons=LineUsed,LSLINT \ CDEF:leastsquareline=LineUsed,POP,slope,COUNT,*,cons,+ \ COMMENT:" " COMMENT:"Last " COMMENT:"Maximum " COMMENT:"Average " COMMENT:"Minimum\l" \ AREA:LineUsed#fe3562:"Used ":STACK GPRINT:Used:LAST:"%%6.3lf %%S" GPRINT:Used:MAX:"%%6.3lf %%S" GPRINT:Used:AVERAGE:"%%6.3lf %%S" GPRINT:Used:MIN:"%%6.3lf %%S\l" \ AREA:LineAvail#cfe694:"Available ":STACK GPRINT:Avail:LAST:"%%6.3lf %%S" GPRINT:Avail:MAX:"%%6.3lf %%S" GPRINT:Avail:AVERAGE:"%%6.3lf %%S" GPRINT:Avail:MIN:"%%6.3lf %%S\l" \ LINE2:LineTotal#3b73fc:"Total " GPRINT:Total:LAST:"%%6.3lf %%S" GPRINT:Total:MAX:"%%6.3lf %%S" GPRINT:Total:AVERAGE:"%%6.3lf %%S" GPRINT:Total:MIN:"%%6.3lf %%S\l" \ LINE1:LineOverdraft#9e0b0f:"Overdraft " GPRINT:Overdraft:LAST:"%%6.3lf %%S" GPRINT:Overdraft:MAX:"%%6.3lf %%S" GPRINT:Overdraft:AVERAGE:"%%6.3lf %%S" GPRINT:Overdraft:MIN:"%%6.3lf %%S\l" \ LINE1:leastsquareline#FF9900:"Trend"
Windows binaries are here and all downloads. I’m using 1.3.8 RRDtool version.
Right now I’m also working on other monitoring scripts.
Graphs, that will show user session for each published apps or desktops (or all):
Graphs, that will show server count for each load range (some kind of map of server “heat”):
If you think, that this license monitoring tool is usefull please let me know using comments below. If you are interested in other usage of RRDtool (in Citrix environment) please let me know.
Update 2016-10-04:
All script are now places on my github.
Definitely interested in what you have done so far. I also have been working on using both PowerShell and RRD and could share some of what I have done with you.
Hello Devante,
I’m really happy, that you are interested in my stuff. I send you an email to contact me in private, to discuss what have you done so far.
Hello Jarek,
I like your RDDTool Related Citrix Licensing Script…. Could you share with me other Citrix Related Scripts Please
Hi Jarek,
Nice tool. Any chance you can expand to multi-tenant license reporting? thanks.
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]
Hello Jarek,
The script is very usefull and I will use it in my projects. To make it more automated I modified your script to set license type to $PLD variable and use variable instead of hardcoded XenDesktop license type.
$PLD = gwmi -class “Citrix_GT_License_Pool” -Namespace “ROOT\CitrixLicensing” |select pld |where pld -notlike “ctxlsdiag”
Regards
Andrzej
Dear Jarek,
how far have you come with the graphs showing user sessions for each published apps or desktops ? Anything new on that? As it looks absolutely fantastic! Great job!
Alex
Thanks a lot for sharing your work!
It helped me a lot and I’m waiting for other monitoring scripts.
Riccardo
Thanks you for script !! Its very usefull !!
I am interested for other monitoring scripts.
hey there, we are hoping you can help. Our license server is running on windows server 2008 R2 and are trying to use the rrdtool as per your instructions above but get ERROR: can’t parse argument ‘\’ when running from an Admin command prompt. We were hoping you could point us in the tight direction
Hi,
I’m very interrested in your scripts about Citrix. Can you send me the ones at the end of your article please ?
Thanks.
Dear Jarek
awesome stuff! I’d be very interested in your License Monitoring Tool as well as other Tools you might be developing right now. As we’re a Citrix Service Provider I’d love to implement your scripts in a PoC. Could you provide some download links and/or Information on how to implement your Tools. In case I could provide you with some help. I’ll be more than happy to Support you.
Many thanks
Alex
Great work Jarek! Thanks!
Dear Jarek,
the same issue like QLDC on 03/05/2016, 00:25:
C:\CTX>CtxLicUsage_RRDCreate.bat
C:\CTX>c:\CTX\RRDtool\rrdtool.exe create CtxLicUsage.rrd \
ERROR: can’t parse argument ‘\’
C:\CTX>–start now-10m –step 300 \
Der Befehl “–start” ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
C:\CTX>DS:total:GAUGE:450:0:U \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>DS:used:GAUGE:450:0:U \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>DS:avail:GAUGE:450:0:U \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>DS:overdraft:GAUGE:450:0:U \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>RRA:AVERAGE:0.5:1:2880 \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>RRA:AVERAGE:0.5:3:2880 \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>RRA:AVERAGE:0.5:9:2880 \
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
C:\CTX>RRA:AVERAGE:0.5:54:2880
Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.
Any idea ?
thx Marco
Hi Jarek,
How are you doing..Nice Script with Graphs.. Looks promising… 🙂
Can you please guide me. I’m getting below error in the first step itself..
C:\CTX\RRDtool>rrdtool create CtxLicUsage.rrd –start now-10m \
ERROR: can’t parse argument ‘\’
C:\CTX\RRDtool>–step 300 \
‘–step’ is not recognized as an internal or external command,
operable program or batch file.
C:\CTX\RRDtool>DS:total:GAUGE:450:0:U \
The filename, directory name, or volume label syntax is incorrect.
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]
[…] Sobel – Monitoring Citrix Licenses usage – Graphs using WMI, Powershell and RRDtool. This script generates a graph similar to the […]