<?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; Monitoring</title>
	<atom:link href="https://www.crummylogic.com/wordpress/?feed=rss2&#038;tag=monitoring" 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>
		<item>
		<title>New Nagios Plugin</title>
		<link>https://www.crummylogic.com/wordpress/?p=106</link>
		<comments>https://www.crummylogic.com/wordpress/?p=106#comments</comments>
		<pubDate>Mon, 30 Sep 2013 14:44:37 +0000</pubDate>
		<dc:creator><![CDATA[jrdalrymple]]></dc:creator>
				<category><![CDATA[Technology junk]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://www.jrssite.com/wordpress/?p=106</guid>
		<description><![CDATA[Last Friday going into the weekend I ran across a snapshot on one of my VMware hosts almost 160 days old, OUCH. The right tool to keep that from happening is definitely Nagios. NagiosExchange didn&#8217;t really have a solution for my problem that I could find. Somebody has written a snapshot age tool in PowerShell &#8230; <a href="https://www.crummylogic.com/wordpress/?p=106" class="more-link">Continue reading <span class="screen-reader-text">New Nagios Plugin</span> <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Last Friday going into the weekend I ran across a snapshot on one of my VMware hosts almost 160 days old, OUCH. The right tool to keep that from happening is definitely Nagios. NagiosExchange didn&#8217;t really have a solution for my problem that I could find. Somebody has written a snapshot age tool in PowerShell but I&#8217;m not interested in having plugins run on hosts that aren&#8217;t my main Nagios server. I was given a fun project to work on.</p>
<p>The vSphere Command Line Interface (formerly the PERL toolkit if I&#8217;m not mistaken) was of little help. It didn&#8217;t really give me any interface into snapshot data at all. I decided the simplest solution would be to work right on the BusyBox console. I started Friday around noon and working on it here and there over a couple days came up with a usable product yesterday morning:</p>
<pre>[jrdalrymple@nagios ~]$ /usr/local/nagios/libexec/check_snapshot.py
No password specified
usage: check_snapshot.py -H hostname [-U username] &lt;-P password | -f PasswordFile&gt;</pre>
<pre>[jrdalrymple@nagios ~]$ sudo /usr/local/nagios/libexec/check_snapshot.py -H 172.16.100.11 -U nagioschk -f /home/nagios/.check_esxi_hw.pw -w 10 -c 20

3 VMs are CRITICAL
Guest example1.domain.local has snapshot 24 days old!
Guest example2.domain.local has snapshot 28 days old!
Guest example3.domain.local has snapshot 26 days old!</pre>
<p><a href="http://www.jrssite.com/wordpress/wp-content/uploads/2013/09/Clipboard03.jpg"><img alt="Clipboard03" src="http://www.jrssite.com/wordpress/wp-content/uploads/2013/09/Clipboard03.jpg" /></a></p>
<p>The results between my command line run and the Nagios GUI aren&#8217;t the same because I gave the Nagios check different thresholds.</p>
<p>I&#8217;ll probably put it up on Nagios Exhange at some point. For now I&#8217;ll just feel accomplished.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.crummylogic.com/wordpress/?feed=rss2&#038;p=106</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
