<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bits of Arrogance &#187; cacti</title>
	<atom:link href="https://www.crummylogic.com/wordpress/?feed=rss2&#038;tag=cacti" rel="self" type="application/rss+xml" />
	<link>https://www.crummylogic.com/wordpress</link>
	<description>Making myself pervasive</description>
	<lastBuildDate>Wed, 04 Oct 2017 17:25:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.4</generator>
	<item>
		<title>Monitor Citrix License Usage with Cacti on Linux</title>
		<link>https://www.crummylogic.com/wordpress/?p=181</link>
		<comments>https://www.crummylogic.com/wordpress/?p=181#comments</comments>
		<pubDate>Thu, 13 Feb 2014 00:44:24 +0000</pubDate>
		<dc:creator><![CDATA[jrdalrymple]]></dc:creator>
				<category><![CDATA[Technology junk]]></category>
		<category><![CDATA[cacti]]></category>
		<category><![CDATA[citrix]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[XenApp]]></category>

		<guid isPermaLink="false">http://www.jrssite.com/wordpress/?p=181</guid>
		<description><![CDATA[There is this: http://forums.cacti.net/about25193.html It&#8217;s useless if your Cacti host is running on a non-Windows host. The suggestion to use wmic is alright, but for some reason the Linux wmic binary doesn&#8217;t query properly: bash-4.1$ /usr/bin/wmic --namespace='root\CitrixLicensing' --authentication-file='/etc/cacti/cactiwmi.pw' //hostname.domain.local 'SELECT Count FROM Citrix_GT_License_Pool' CLASS: Citrix_GT_License_Pool Count&#124;DUP_GROUP&#124;FLOAT_OK&#124;HOST_BASED&#124;HOSTID&#124;PLATFORMS&#124;PLD&#124;Subscriptionate&#124;USER_BASED&#124;VendorString6&#124;8&#124;False&#124;0&#124;&#124;&#124;MPS_ADV_CCU&#124;20141216000000.000000+000&#124;0&#124;;LT=Retail;GP=720;CL=ADV,STD,AST;SA=1;ODP=0 I haven&#8217;t the foggiest why, nor did I care &#8230; <a href="https://www.crummylogic.com/wordpress/?p=181" class="more-link">Continue reading <span class="screen-reader-text">Monitor Citrix License Usage with Cacti on Linux</span> <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>There is this:</p>
<p><a href="http://forums.cacti.net/about25193.html">http://forums.cacti.net/about25193.html</a></p>
<p>It&#8217;s useless if your Cacti host is running on a non-Windows host. The suggestion to use wmic is alright, but for some reason the Linux wmic binary doesn&#8217;t query properly:</p>
<pre>bash-4.1$ /usr/bin/wmic --namespace='root\CitrixLicensing' --authentication-file='/etc/cacti/cactiwmi.pw' //hostname.domain.local 'SELECT Count FROM Citrix_GT_License_Pool'
CLASS: Citrix_GT_License_Pool
Count|DUP_GROUP|FLOAT_OK|HOST_BASED|HOSTID|PLATFORMS|PLD|Subscriptionate|USER_BASED|VendorString6|8|False|0|||MPS_ADV_CCU|20141216000000.000000+000|0|;LT=Retail;GP=720;CL=ADV,STD,AST;SA=1;ODP=0</pre>
<p>I haven&#8217;t the foggiest why, nor did I care to dig into the source when I&#8217;m such a pro at spaghetti stringing weird crap together to achieve a goal. The answer is the ability to run Powershell scripts natively on Linux, but it hasn&#8217;t happened yet.</p>
<p>Without describing the thought process that got me there I&#8217;ll just describe the final product. In Cacti it you start with a &#8220;Data Input Method,&#8221; this is what it looks like:</p>
<p><a href="http://www.jrssite.com/wordpress/wp-content/uploads/2014/02/Data-Input-Method.jpg"><img class="alignnone size-medium wp-image-182" alt="Data Input Method" src="http://www.jrssite.com/wordpress/wp-content/uploads/2014/02/Data-Input-Method-300x117.jpg" width="300" height="117" /></a></p>
<p>The script is a simple bash script that looks like this:</p>
<pre>#!/bin/sh
ssh $1 -l $2 "powershell.exe -inputformat none -noprofile -File \"C:\cygwin64\home\sshd\ctx_license_check.ps1\""</pre>
<p>The reason I didn&#8217;t run ssh directly from cacti is because passing the parameters isn&#8217;t really easy/possible after Cacti does all of its munging on the script. In case it isn&#8217;t obvious the script ssh&#8217;s to the host specified by argument 1 using the username specified by argument 2 and then runs a Powershell script. Since this script is run by the cacti user I had to configure passwordless (shared key) logon for that user from my Linux host to my license server. In order for ANY of this to work I had to install Cygwin and sshd on my license server, the tutorial I followed is here:</p>
<p><a href="http://www.howtogeek.com/howto/41560/how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/">http://www.howtogeek.com/howto/41560/how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/</a></p>
<p>I created a local user on my Windows box, sshd. That user needed administrative privileges, which sucks but since it&#8217;s a local account I don&#8217;t care too much as the password for the account can be shredded at this point. Also I did have to go into the WMI security properties for the WMI namespace &#8220;root\CitrixLicensing&#8221; and grant enable rights for that user there:</p>
<p><a href="http://www.jrssite.com/wordpress/wp-content/uploads/2014/02/Clipboard02.jpg"><img class="alignnone size-medium wp-image-186" alt="Clipboard02" src="http://www.jrssite.com/wordpress/wp-content/uploads/2014/02/Clipboard02-300x231.jpg" width="300" height="231" /></a></p>
<p>The last part to get the data out of the host is the Powershell script. I&#8217;m not a Powershell expert, or even a rookie really. This is what I wrote to get the data:</p>
<pre>$inuse = Get-WmiObject -namespace root\citrixlicensing -class Citrix_GT_License_Pool | Select-Object -ExpandProperty InUseCount
$total = Get-WmiObject -namespace root\citrixlicensing -class Citrix_GT_License_Pool | Select-Object -ExpandProperty Count
Write-host "inuse:$inuse total:$total"</pre>
<p>Suggestions are welcome, it works.</p>
<p>Cacti&#8217;s expected return values are something like this:</p>
<pre>value_name1:value value_name2:value</pre>
<p>My actual output looked like this:</p>
<pre>inuse:2 total:6</pre>
<p>This isn&#8217;t going to be a how to build graphs in Cacti tutorial, so with that I&#8217;m happy to attach my graph template and all this. You can import it on your end to see what I did. This is what the final result looks like:</p>
<p><a href="http://www.jrssite.com/wordpress/wp-content/uploads/2014/02/Clipboard021.jpg"><img class="alignnone size-medium wp-image-189" alt="Clipboard02" src="http://www.jrssite.com/wordpress/wp-content/uploads/2014/02/Clipboard021-300x101.jpg" width="300" height="101" /></a></p>
<p>&nbsp;</p>
<p>Edit:</p>
<p>After installing some more licenses the check broke. My PS1 started returning results like</p>
<pre>inuse:0 4 total:5 6</pre>
<p>which is representative of 2 seperate license files. It was simple enough to fix as the results from the WMI query com reliably through as arrays &#8211; no string manipulation necessary:</p>
<pre>$inuse = Get-WmiObject -namespace root\citrixlicensing -class Citrix_GT_License_Pool | Select-Object -ExpandProperty InUseCount
$total = Get-WmiObject -namespace root\citrixlicensing -class Citrix_GT_License_Pool | Select-Object -ExpandProperty Count
$suminuse = 0
$sumtotal = 0
foreach ($c in $inuse)
{$suminuse += $c}
foreach ($c in $total)
{$sumtotal += $c}
Write-host "inuse:$suminuse total:$sumtotal"</pre>
<p>Back in business!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.crummylogic.com/wordpress/?feed=rss2&#038;p=181</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
