<?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>Carlos&#039; Corner</title>
	<atom:link href="http://cars.lostroncos.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://cars.lostroncos.org</link>
	<description>The tired geek-dad in the corner</description>
	<lastBuildDate>Tue, 23 Feb 2010 17:55:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple Neverfail Monitoring with Zabbix part 2</title>
		<link>http://cars.lostroncos.org/2010/02/23/simple-neverfail-monitoring-with-zabbix-part-2/</link>
		<comments>http://cars.lostroncos.org/2010/02/23/simple-neverfail-monitoring-with-zabbix-part-2/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 17:53:36 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[neverfail]]></category>
		<category><![CDATA[zabbix]]></category>
		<category><![CDATA[neverfail for Exchange]]></category>
		<category><![CDATA[neverfail heartbeat]]></category>
		<category><![CDATA[reg_dword_big_endian]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=363</guid>
		<description><![CDATA[Recap
<p>So in the previous post I put together a simple script for getting the data out of a specified registry entry that handled the REG DWORD BIG ENDIAN data type.  In this one I&#8217;ll go over the general process of getting the registry based perf data into Zabbix and setting up  alerting based on [...]]]></description>
			<content:encoded><![CDATA[<h2>Recap</h2>
<p>So in the<a href="http://cars.lostroncos.org/2009/05/31/simple-monitoring-of-neverfail-with-zabbix-part-1/"> previous post</a> I put together a simple script for getting the data out of a specified registry entry that handled the REG DWORD BIG ENDIAN data type.  In this one I&#8217;ll go over the general process of getting the registry based perf data into Zabbix and setting up  alerting based on it.</p>
<h2>Setting up Zabbix</h2>
<p>I won&#8217;t cover the actual installation of Zabbix here, but before we can put data into Zabbix we need to add the counters/items that I will be populating in the future. The first thing I need to do is determine exactly what those counters are and which of the nodes they need to come from.</p>
<table border="1">
<tbody>
<tr>
<th>Registry Path/Value</th>
<th>Node</th>
<th>Description</th>
</tr>
<tr>
<td>\Neverfail\R2\Performance\CurrentThroughput</td>
<td>Active</td>
<td>Nominally the throughput  of data between the two nodes</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\MegaBytessent</td>
<td>Active</td>
<td># of Megabytes sent</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\MegabytesReceived</td>
<td>Active</td>
<td># of MB received</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\OldestUnsafeupdatequeueentry</td>
<td>Active</td>
<td>Age of the oldest item in the Unsafe Queue</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\UnsafeUpdateQueueSize</td>
<td>Active</td>
<td>How much data is in the Unsafe Queue waiting to be passed to the passive node</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\UnsafeUpdateQueueSize (dup)</td>
<td>Active</td>
<td>Same as above but I want to measure the rate of growth as a possible factor in alerting</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\KBDispatchedFromUnsafeQueue</td>
<td>Active</td>
<td>How much total data has been sent from the unsafe queue</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\Oldestsafeupdatequeueentry</td>
<td>Passive</td>
<td>The age of the oldest item in the safe queue</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\safeUpdateQueueSize</td>
<td>Passive</td>
<td>Size of the Safe Queue</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\safeUpdateQueueSize(dup)</td>
<td>Passive</td>
<td>Same as above but I want to measure the rate of growth as a possible factor in alerting</td>
</tr>
<tr>
<td>\Neverfail\R2\Performance\KBDispatchedFromsafeQueue</td>
<td>Passive</td>
<td>How much total data has been written from the Safe Queue</td>
</tr>
<tr>
<td>\JavaSoft\Prefs\Neverfail\current\/Registry/State/Manager\/Status\/Value</td>
<td>Active</td>
<td>Current status of the registry synchronization.</td>
</tr>
<tr>
<td>\JavaSoft\Prefs\Neverfail\current\/New/File/State/Mgr\/Synchronization/Status\/Tag</td>
<td>Active</td>
<td>Current file synchronization status.</td>
</tr>
<tr>
<td>\JavaSoft\Prefs\Neverfail\current\/Controller\/Is/Primary/Server</td>
<td>Active</td>
<td>Is the active server the primary or not. From this I can tell which node is active.</td>
</tr>
</tbody>
</table>
<p>Because I have multiple Neverfail clusters in my environment I will create a template in Zabbix that has all the necessary counters associated with it that I can then apply to the hosts rather than adding them manually to each host.  Since a host can have multiple templates assigned to it I&#8217;ll also include a new &#8220;application&#8221; called Neverfail to help with separating Neverfail counters from any other counters that might be associated with a host (ex: Exchange counters).</p>
<p>To help with some of the drudgery associated with manually creating all the items, I&#8217;ve provided  <a href="http://cars.home.lostroncos.org/wp-uploads/2010/02/zbx_Template_NeverfailCluster.xml">a version of the template</a> that can simply be imported into Zabbix. The template includes all of the counters from above as well as a couple of basic triggers for alerting.</p>
<p>Here are a couple of short videos that walk through manually creating a template, and importing the one I&#8217;ve provided.</p>
<table border="0" width="550px">
<tbody>
<tr>
<td><a href="http://cars.home.lostroncos.org/wp-uploads/2010/02/zbx_create_template.swf" target="_blank"><img class="alignnone size-full wp-image-493" title="Creating a template" src="http://cars.home.lostroncos.org/wp-uploads/2010/02/create_video.png" alt="Creating a template" width="250" height="175" /><br />
Creating a template</a></td>
<td><a href="http://cars.home.lostroncos.org/wp-uploads/2010/02/zbx_import_and_create_template.swf" target="_blank"><img class="alignnone size-full wp-image-493" title="Importing a template" src="http://cars.home.lostroncos.org/wp-uploads/2010/02/import_video.png" alt="Importing a template" width="250" height="175" /><br />
Importing the Neverfail Template into Zabbix</a></td>
</tr>
</tbody>
</table>
<p>Sharp eyes might notice that I&#8217;m capturing  bothUnsafeUpdateQueueSize and safeUpdateQueueSize twice.  In doing so these values are being treated differently. The first is a simple measurement of how much data is in the queue.</p>
<h2>About Zabbix_sender</h2>
<p>Now turning our attention to how we get the info into Zabbix let&#8217;s look at Zabbix_sender.  It&#8217;s available a pre-compiled binary for Windows from <a href="http://www.zabbix.com/download.php">Zabbix&#8217;s website</a>. Getting it ready is as simple as unzipping the download and putting the executable somewhere. By running <em>zabbix_sender -h</em> we can see it can take a number of options.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\Temp&amp;gt;zabbix_sender -h<br />
ZABBIX send v1.6.2 (16 January 2009)<br />
<br />
usage: zabbix_sender [-Vhv] {[-zpsI] -ko | [-zpI] -i &amp;lt;file&amp;gt;} [-c &amp;lt;file&amp;gt;]<br />
<br />
Options:<br />
-c &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Specify configuration file<br />
-z &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hostname or IP address of ZABBIX Server.<br />
-p &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Specify port number of server trapper running on the server. Default is 10051.<br />
-s &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Specify hostname or IP address of a host.<br />
-I &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Specify source IP address<br />
-k &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Specify metric name (key) we want to send.<br />
-o &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Specify value of the key.<br />
-i<br />
<br />
&lt;input /&gt; Load values from input file.<br />
Each line of file contains:<br />
.<br />
-v &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Verbose mode<br />
Other options:<br />
-h &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Give this help.<br />
-V &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Display version number.</div></div>
<p>The ones I use  are -s, -z, -k and -o.  So a typical command line for me would look something like:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">C:\temp\Zabbix_sender -z zabbix.crtcorp.com -s neverfail01 -k&quot;nf_cluster[file_sync_status]&quot; -o &quot;/Synchronized&quot;</div></div>
<p>Breaking down the command line:</p>
<ul>
<li><em><strong>zabbix.crtcorp.com</strong></em> is the Zabbix server we&#8217;re sending this data to</li>
<li><strong><em>neverfail01</em></strong> is the Neverfail node we&#8217;re sending information about</li>
<li>the key for the Zabbix item (i.e. counter) we want the information associated with is <strong><em>nf_cluster[file_sync_status]</em></strong>;</li>
<li>the value we want in the key is  &#8221;<strong><em>/Synchronized</em></strong>&#8220;</li>
</ul>
<p>In the example the value we&#8217;re putting into Zabbix is a string rather than a numerical value. Here&#8217;s an example with a numeric value being put into Zabbix:</p>
<p>C:\temp\Zabbix_sender -z zabbix.crtcorp.com -s neverfail01 -k&#8221;nf_cluster[throughput]&#8221; -o &#8220;103453&#8243;</p>
<p>Here we&#8217;re specifying the item with key <strong><em>nf_cluster[throughput]</em></strong> and giving it a value of <strong><em>103453</em></strong>.</p>
<h3>Adding Zabbix_Sender</h3>
<p>Now what I  needed to do is to combine the script I wrote earlier with zabbix_sender to actually put the registry data into Zabbix. So  I added a new function to the GetRegValue.vbs script to execute the actual zabbix_send. It is pretty straightforward it builds a formulaic command line and then executes it. You&#8217;ll notice there is no error checking.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">'###################################################################################<br />
Function Zabbix_Send(ZabbixKey,Value)<br />
Dim WshShell, oExec, CommandLine<br />
Set WshShell = CreateObject(&quot;WScript.Shell&quot;)<br />
'Build Our Command line so we can also echo it to console<br />
'Ex zbx send cmd line = C:\temp\Zabbix_sender -z&quot;wv-zabbix-01&quot; -s&quot;neverfail01&quot; &nbsp;-k&quot;nf_cluster[file_sync_status]&quot; -o &quot;/Synchronized&quot;<br />
CommandLine = ZBXSend &amp;amp; &quot; -v -z&quot;&quot;&quot; &amp;amp; ZBXServer &amp;amp; &quot;&quot;&quot; -s&quot;&quot;&quot; &amp;amp; ZBXClient &amp;amp; &quot;&quot;&quot; -k&quot;&quot;&quot; &amp;amp; ZabbixKey &amp;amp; &quot;&quot;&quot; -o &quot;&quot;&quot; &amp;amp; Value &amp;amp; &quot;&quot;&quot;&quot;<br />
WScript.Echo &quot;Commandline is [&quot; &amp;amp; CommandLine &amp;amp; &quot;]&quot;<br />
'Execute our command line<br />
Set oExec = WshShell.Exec(CommandLine)<br />
End Function</div></div>
<p>The next step is to modify the main body of the original GetRegValue script to turn it into a function. I then changed the WScript.Echos so that we were returning the registry value rather than simply writing it to the console.  (WScript.Echo HexToDec(HexValue) -&gt; GetRegValue = HexToDec(HexValue) , Wscript.Echo strValue -&gt; GetRegValue=strValue, and so on).  At the end we have this script which is good for reading <strong><em>one</em></strong> specified registry value and then inserting it into Zabbix.</p>
<p>Since there are a number of values we want to put into Zabbix we need to think about how to approach this given that the script only handles one value at a time.  What I settled on was a a batch file that used a<strong><em> for</em></strong> loop to go through a file with a list of registry based perf counters related to Neverfail.  The script as it now stands needs three arguments passed to it. It needs the ZabbixKey, the registry key path, and the registry value .  For values I want to get from the passive node the registry path needs to include the private IP address of the passive node (ex: \\10.0.0.2\HKLM\Software\Neverfail\R2\Performance) so that reg.exe knows where to go get them from.  The script can then query the registry using the path and value combination to get the data which it can then send to Zabbix using the key specified on the command line.  So having the list of registry values from the part 1 post I&#8217;m able to put together my file.</p>
<p>Because  I need to specify a delimiter to the <strong><em>for</em></strong> command and I use commas &#8216;,&#8217; in the Zabbix keys that I&#8217;ve defined, I need to use something else as a delimiter for my input file, so I&#8217;ve settled on using a pipe symbol as shown below.</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nf_cluster[throughput]|HKLM\Software\Neverfail\R2\Performance|CurrentThroughput<br />
nf_cluster[MB_sent]|HKLM\Software\Neverfail\R2\Performance|MegaBytessent<br />
nf_cluster[MB_recvd]|HKLM\Software\Neverfail\R2\Performance|MegabytesReceived<br />
nf_q[unsafe,age]|HKLM\Software\Neverfail\R2\Performance|OldestUnsafeupdatequeueentry<br />
nf_q[unsafe,size]|HKLM\Software\Neverfail\R2\Performance|UnsafeUpdateQueueSize<br />
nf_q[unsafe,rate]|HKLM\Software\Neverfail\R2\Performance|UnsafeUpdateQueueSize<br />
nf_q[unsafe,total_kb_sent]|HKLM\Software\Neverfail\R2\Performance|KBDispatchedFromUnsafeQueue<br />
nf_q[safe,age]|\\10.0.0.2\HKLM\Software\Neverfail\R2\Performance|Oldestsafeupdatequeueentry<br />
nf_q[safe,size]|\\10.0.0.2\HKLM\Software\Neverfail\R2\Performance|safeUpdateQueueSize<br />
nf_q[safe,rate]|\\10.0.0.2\HKLM\Software\Neverfail\R2\Performance|SafeUpdateQueueSize<br />
nf_q[safe,total_kb_sent]|\\10.0.0.2\HKLM\Software\Neverfail\R2\Performance|KBDispatchedFromsafeQueue<br />
nf_cluster[reg_sync_status]|HKLM\Software\JavaSoft\Prefs\Neverfail\current\/Registry/State/Manager\/Status|/Value<br />
nf_cluster[file_sync_status]|HKLM\Software\JavaSoft\Prefs\Neverfail\current\/New/File/State/Mgr\/Synchronization/Status|/Tag<br />
nf_cluster[primary]|HKLM\Software\JavaSoft\Prefs\Neverfail\current\/Controller|/Is/Primary/Server</div></div>
<p>While my batch file  is about 35 lines, it really boils down to one line which does all the real work:</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">for /F &quot;tokens=1-3 delims=|&quot; %%I in (%ZBXKEYS%) do cscript %SENDVALUES% &quot;%%I&quot; &quot;%%J&quot; &quot;%%K&quot;</div></div>
<p>With the environment variables expanded it would look more like;</p>
<div class="codecolorer-container text blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">for /F &quot;tokens=1-3 delims=|&quot; %%I in (zbx_keys_to_send.txt ) do cscript SENDVALUES.vbs &quot;%%I&quot; &quot;%%J&quot; &quot;%%K&quot;</div></div>
<p>This for loop reads in each line of  the text file zbx_keys_to_send.txt and using the pipe symbol as a delimiter reads in the first three tokens/strings of each line and call the SENDVALUES.vbs script with the three tokens/strings as arguments.  The script and input file worked fine when I ran them on the primary node, but not so well when I ran them while the secondary was active. After some troubleshooting I realized  that one thing I didn&#8217;t think through at first wat that I actually need two lists/input files. Since the private IP address I want to use to get data from the passive node&#8217;s registry will change depending on which node is active I&#8217;ll need one list for when the script is sending from the primary node (10.0.0.1)  and another for when the secondary (10.0.0.2) is active. The lists should essentially be identical with the only difference being the IP address specifed for the passive node.</p>
<p><img class="alignnone size-full wp-image-369" title="A generic Neverfail cluster" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/nf_cluster.png" alt="A generic Neverfail cluster" width="474" height="275" /></p>
<p>Now all that is left to do is copy the batch file, the vbscript file and the approapirate inputer to each node in the cluster. Prior to setting up the scehiled task I like to manually run the batch file a few time to make sure  the data is getting populated into Zabbix. To do this I need to use a local account that exists on both nodes (in my case I use the local Administrator account). This is so that the reg.exe util can seamlessly get values from the passive node (assuming the account has the same password on both nodes).</p>
<h3>A little troubleshooting hint.</h3>
<p>When running the script manually I can see each time the VBScript file calls zabbix_sender and whether or not that submission was successful. Running zabbix_sender and mistyping the key was not an common issue when I was putting this together. Fortunately zabbix_sender lets me know what happened when I attempted to submit data.  As an example, below is the output I get when trying to submit a value for the nf_q[safe,size] key, if I mistype the key as nfq[safe,size]</p>
<p><img class="alignnone size-full wp-image-390" title="zbx_send_failed" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_send_failed.png" alt="zbx_send_failed" width="739" height="86" /></p>
<p>I can see that it reports that I have 1 failed item, and no Processed items. When I run it without any typos (intentional or otherwise) I get:</p>
<p><img class="alignnone size-full wp-image-389" title="zbx_send_good" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_send_good.png" alt="zbx_send_good" width="718" height="85" /></p>
<p>Now I can see that I had 1 item processed successfully and no Failed ones.</p>
<h2>Setting up Alerting</h2>
<p>If you import the template I&#8217;ve provided it should have also created four triggers that can be used to generate actions within Zabbix.</p>
<p><img class="alignnone size-full wp-image-392" title="template_triggers" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/template_triggers.png" alt="template_triggers" width="851" height="151" /></p>
<p>These triggers are based on situations I&#8217;ve run into in my environment that I want to be aware of.  The first is when the size of either the Safe or Unsafe queue has been above 2GB for over an hour. Neverfail was great at letting me know the queue was full and it was going to stop replicating but not so much on the warning me it was happening front.  I generally wanted to be aware well before we got to that state where it stopped replicating and these triggers are a way of warning me something is going on.  The second situation is when data to be replicated has been sitting in one of the queue&#8217;s for more than a specified amount of time.  This is similar to watching the queue get beyond a certain size as the first two triggers do but is helpful in situations where there isn&#8217;t a whole of data changing on the active node(i.e. over weekends).</p>
<p>It is of course  possible to change these and set them to what fits for your environment and even to add other triggers. In later versions of this monitoring I&#8217;ve added some other counters/keys related to the task state using the nfcmd.exe command line tool. This allows me to see when a server is doing a full system check or even the dreaded &#8220;internal system task&#8221; as well as how much progress it&#8217;s made.  Some example screenshots are included below.</p>
<table border="0" width="100%">
<tbody>
<tr align="center">
<td><div id="attachment_394" class="wp-caption alignnone" style="width: 160px"><br />
<a rel="lightbox[nf]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_data.png"><img class="size-thumbnail wp-image-394" title="Sample Data for one cluster" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_data-150x150.png" alt="Sample Data for one cluster" width="150" height="150" /></a><p class="wp-caption-text">Sample Data for one cluster</p></div></td>
<td><div id="attachment_396" class="wp-caption alignnone" style="width: 160px"><a rel="lightbox[nf]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_landscape.png"><img class="size-thumbnail wp-image-396" title="Overview of all the clusters in my environment" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_landscape-150x150.png" alt="Overview of all the clusters in my environment" width="150" height="150" /></a><p class="wp-caption-text">Cluster Overview</p></div></td>
<td><div id="attachment_397" class="wp-caption alignnone" style="width: 160px"><a rel="lightbox[nf]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_safeq_size_graph.png"><img class="size-thumbnail wp-image-397 " title="Graph of the Safe Queue size" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_safeq_size_graph-150x150.png" alt="Graph of the Safe Queue size" width="150" height="150" /></a><p class="wp-caption-text">Sample Graph of the Safe Queue size</p></div></td>
<td><div id="attachment_395" class="wp-caption alignnone" style="width: 160px"><a rel="lightbox[nf]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_fullcheck.png"><img class="size-thumbnail wp-image-395" title="Enhanced view showing a Full System Check that is 3% complete." src="http://cars.lostroncos.org/wp-content/uploads/2010/02/zbx_nf_fullcheck-150x150.png" alt="Enhanced view showing a Full System Check that is 3% complete." width="150" height="150" /></a><p class="wp-caption-text">Enhanced view</p></div></td>
</tr>
</tbody>
</table>
<p>The three files I use are included here:</p>
<ul>
<li><a href="http://cars.lostroncos.org/wp-content/uploads/2010/02/Do_Zabbix.cmd.txt">DO_Zabbix.cmd</a> &#8211; The batch file that reads the input file with reg values &amp; zabbix keys and calls SendRegValue.vbs</li>
<li><a href="http://cars.lostroncos.org/wp-content/uploads/2010/02/SendRegValue.vbs.txt">SendRegValue.vbs</a> &#8211; The vbscript file that actually reads the registry entry and does any necessary conversions to send the value to Zabbix</li>
<li><a href="http://cars.lostroncos.org/wp-content/uploads/2010/02/zabbix_keys_to_send.txt">zabbix_keys_to_send.txt</a> &#8211; the input file used by DO_Zabbix.cmd. This version is the one I run when the primary node is active. IP addresses would need to be changed for this to run on a passive node.</li>
</ul>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><em>A few additional notes:</em></p>
<p><em>Because Neverfail  is continually pushing the perf data to the registry it does happen on occasion that the script will catch spuriously large or odd values for some counters. </em></p>
<p><em>If I were to use the zabbix_agent on my Neverfail nodes it is possible to include all this same monitoring within the agents configuration so that the agent pushes the data rather than using zabbix_sender via a scheduled task. <em>However that&#8217;s a post for some other time&#8230;<br />
-crt</em></em></p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2010/02/23/simple-neverfail-monitoring-with-zabbix-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simulating a more interesting environment with Vyatta and VMware ESXi &#8211; pt 2</title>
		<link>http://cars.lostroncos.org/2010/02/18/a-more-interesting-environment-with-vyatta-and-vmware-pt2/</link>
		<comments>http://cars.lostroncos.org/2010/02/18/a-more-interesting-environment-with-vyatta-and-vmware-pt2/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 22:37:37 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Home Lab]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[vyatta]]></category>
		<category><![CDATA[ESX]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=343</guid>
		<description><![CDATA[<p>In an earlier post I went through the process of coming up with a solution to be able to test an Exchange 2003 to Exchange 2010 migration using VMs. In order to simulate a multi-site AD environment I wanted to use Vyatta based routers to create my network infrastructure. In this post I&#8217;ll actually walk [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cars.lostroncos.org/2010/02/17/a-more-interesting-environment-with-vyatta-and-vmware/">In an earlier post</a> I went through the process of coming up with a solution to be able to test an Exchange 2003 to Exchange 2010 migration using VMs. In order to simulate a multi-site AD environment I wanted to use Vyatta based routers to create my network infrastructure. In this post I&#8217;ll actually walk through the process of setting up the ESX and theinternal router. In the next post(s) I&#8217;ll go into configuring the DMZ and internet routers and firewalls. As a reminder the environment I want to set up will look like this&#8230;</p>
<p><a rel="lightbox[100]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga8.png"><img class="alignnone size-medium wp-image-299" title="Final Environment" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga8-300x139.png" alt="Final Environment" width="300" height="139" /></a>.</p>
<p>In order to actually be able to implement this I first had to go configure the appropriate networking configuration on each of the ESXi hosts.</p>
<p>First I needed to create a virtual switch utilizing the NIC attached to the crossover cable. This is done by going to the &#8220;Configuration&#8221; tab for the ESX host within the vSphere Client.</p>
<p><a rel="lightbox[21]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part21.png"><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part21.png" alt="" width="535" height="176" /></a></p>
<p>Clicking the &#8220;Add Networking&#8221; option will walk one through the wizard to configure the new switch. I started by choosing &#8220;Virtual Machine&#8221; on the Connection Type Screen.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part22.png" alt="" /></p>
<p>On the next page I choose to create a new virtual switch and pick the appropriate physical NIC that will be used to communicate with the other host. (If I had the capacity to put all the VMs one one host I could create the vSwitch without having to specify a network adapter)</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part23.png" alt="" /></p>
<p>Then I created an initial Port Group and specified a VLAN ID for it. In this case for the Remote Site (192.168.3.X/24) I&#8217;m specifying VLAN ID 23.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part24.png" alt="" /></p>
<p>Once completed the new virtual switch should look similar to the one shown below.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part25.png" alt="" /></p>
<p>Now that the vSwitch has been created, I can add port groups for the other networks: DMZ (192.168.254.X), Internet (10.0.0.X) and HQ(192.168.2.X).  Each one of these should have a unique VLAN ID associated with it which is also used when these port groups get created on the second host.</p>
<p><span id="more-343"></span></p>
<p>In addition I need to add port groups for the network between the DMZ and Internet router (192.168.5.X), as well as the one between the internal router and the DMZ (192.168.4.X). Because I&#8217;ll put all three routers on the same host, these last two port groups need only exist on that one host.</p>
<p>When all is said and done there should be 6 port groups defined on the vSwitch on the host where I&#8217;ll put the routers and 4 port groups on the other host. Notice that the VLAN IDs for each network match up across the two switches.</p>
<p><a rel="lightbox[26]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part26.png"><img title="Completed vSwitch Configs" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part26.png" alt="" width="544" height="349" /></a></p>
<p>I initially tried this setup using an alpha version 6 of Vyatta but the routers felt a little slow to me (though I have no empirical evidence to back that up) so I went back to using version 5 LiveCDs for the routers as discussed in the earlier entry.</p>
<h2>Building the internal router</h2>
<p>I started by creating a custom VM for the internal or home router with 4 network adapters configured. I used the custom configuration because this VM won&#8217;t actually have a virtual hard disk. The four network adapters will be attached to my home LAN (lostroncos_01), the HQ Site Network, the Remote Site Network and the intranet to DMZ network. (Note: <a href="http://cars.lostroncos.org/2008/09/18/using-vyatta-with-vmware/">This post has a more detailed description</a> of the process I used to create Vyatta routers. )</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part27.png" alt="" /></p>
<p>After powering on the router and opening the VM console I like to enable the NIC on my home network and ssh so I can do the rest of the configuration via an ssh client such as Putty. Once the VM has initially been powered on, I can go back and look at the settings and determine the MAC address of the NIC attached to my home network (lostroncos_01) is 00:0c:29:76:e2:07. Upon logging into the VM console I can go into configure mode by entering the command &#8220;configure&#8221; and then get a list of the interfaces the router knows about by entering &#8220;show interfaces&#8221;.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part28.png" alt="" /><br />
The one I&#8217;m interested in initially configuring is eth0. I can tell because the MAC matches the one I took note of earlier. To configure it to use 192.168.1.254 as it&#8217;s address and enable ssh I can do the following:</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part29.png" alt="" /></p>
<p>Let&#8217;s look at these commands in a little more detail.</p>
<p>The  set interfaces command can take a wide variety of arguments. Here I&#8217;m specifying that I want to work on an ethernet interface. Other interface types include adsl, bonding, bridge, loopback, multilink, openvpn, serial, tunnel and wirelessmodem.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part210.png" alt="" /></p>
<p>Even after specifying the type as <strong><em>ethernet</em></strong> and the particular interface (eth0) I can still use one of several subcommands/options.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part211.png" alt="" /></p>
<p>Because I&#8217;m using VMs and a fairly generic setup I really only need to worry about the <strong><em>address</em></strong> option. So I specify the address and netmask notation by specifying the number of bits to use for the netmask (24).</p>
<p>The next command <strong><em>&#8220;set service ssh</em></strong>&#8221; simply enables the SSH server.</p>
<p>Now I&#8217;ve configured the interface and enabled SSH, but the settings haven&#8217;t been made active. That&#8217;s what the<strong><em> &#8220;commit&#8221;</em></strong> command does.</p>
<p>Executing the &#8220;<strong><em>show interfaces</em></strong>&#8221; command again I can see that the IP(v4) address is set for eth0 but not any of the other interfaces. Now I can use my ssh client to connect to the VM to finish the configuration. (One can also use the VMware console to perform all of the configuration steps, I just prefer an external SSH client).</p>
<p>After making sure the MAC addresses and networks match up the way I think they should, I can set the address for each of the other interfaces and commit the changes. Then I can exit the configuration mode by typing &#8220;<strong><em>exit</em></strong>&#8221; and save the configuration to the virtual floppy using the &#8220;<strong><em>init-floppy</em></strong>&#8221; command.  This then ensures that my configuration will survive reboots of the router.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part212.png" alt="" /></p>
<p>One of the other things than can be helpful to do is to use the &#8220;<strong><em>description</em></strong>&#8221; option with  set interfacse to provide a little more information when logged into the router.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part213.png" alt="" /></p>
<p>After doing this for each interface and then committing the changes I can see the descriptions when doing show interfaces from either the configure mode</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part214.png" alt="" /></p>
<p>Or from the actual router shell</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part215.png" alt="" /></p>
<p>Since I happen to  already have VMs on both the HQ and Remote networks I can verify basic connectivity from the router by pinging those VMs as well as my PC.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part216.png" alt="" /></p>
<p>The next trick is to validate that I can ping the HQ and Remote subnets from my physical PC. Since both of those subnets are directly connected to the router I don&#8217;t need to add any static routes on the router. However I do need to add a route on my PC to reach those subnets. Otherwise it&#8217;ll try to use the default gateway out to my ISP (as shown below) which doesn&#8217;t know anything about this lab environment.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part217.png" alt="" /></p>
<p>To reach the 192.168.[2,3,4] subnets I want to use the interface on rtr-home that&#8217;s attached to my home network (192.168.1.254). So using the &#8220;<strong><em>route</em></strong>&#8221; command from a command prompt on my Windows7 machine I can add the route to 192.168.4.X.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part218.png" alt="" /></p>
<p>The route command in this case takes a few arguments…</p>
<p style="margin-left: 27pt">#1 <strong><em>add </em></strong>tells route I&#8217;m adding a new one</p>
<p style="margin-left: 27pt">#2 Next I specify the destination, and since ultimately I&#8217;m trying to get to a subnet we&#8217;ll specify <strong><em>192.168.4.0</em></strong>.</p>
<p style="margin-left: 27pt">#3 &amp; #4 <strong><em>MASK </em></strong>says the next argument is the netmask relative to the destination</p>
<p style="margin-left: 27pt">#5 is the gateway for this destination, in this case the interface on my virtual router that&#8217;s attached to the home network.</p>
<p>Once that&#8217;s done I can then try to ping &amp; tracert the 192.168.4.2 interface on the router again.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part219.png" alt="" /><br />
<img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part220.png" alt="" /></p>
<p>Executing the <strong><em>&#8220;route print&#8221;</em></strong> command from the Command Prompt  I can see the entry for the 192.168.4.X network as I would expect.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part221.png" alt="" /></p>
<p>Now that this particular routing entry appears to be working properly I can re-run the route command with the <strong><em>-p</em></strong> option so that it&#8217;s persistent across reboots of my home PC.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part222.png" alt="" /><br />
Next I need to add routes for the 192.168.2.X and 192.168.3.X networks to the PC as well.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part223.png" alt="" /></p>
<p>At this point, I can try to do a traceroute from my PC to the VM on the HQ Site network that I was able to ping earlier from the router.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part224.png" alt="" /><br />
Because I&#8217;m occasionally paranoid, the next step for me was to connect to the console of the VMs on the HQ (shown below) and Remote (not shown) subnets and verify that I can ping machines on my home LAN across the internal router, rtr-home.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_2236_Part225.png" alt="" /></p>
<p>At this point my internal Vyatta router is routing traffic between subnets it is directly connected to (Home LAN, the HQ Site and Remote Site). Once the DMZ and Internet routers are set up some changes will need to be made on the internal router to get traffic to those non-connected subnets. I&#8217;ll go through that process in a subsequent post.</p>
<p>-crt</p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2010/02/18/a-more-interesting-environment-with-vyatta-and-vmware-pt2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simulating a more interesting environment with Vyatta and VMware ESXi</title>
		<link>http://cars.lostroncos.org/2010/02/17/a-more-interesting-environment-with-vyatta-and-vmware/</link>
		<comments>http://cars.lostroncos.org/2010/02/17/a-more-interesting-environment-with-vyatta-and-vmware/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 07:05:08 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Home Lab]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[ESX]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[vyatta]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=300</guid>
		<description><![CDATA[<p>[Part 2 of this series which involves the actual configuration of the Vyatta routers is now up here -crt]</p>
<p>At work we&#8217;ve recently made the decision to migrate to Exchange 2010 from Exchange 2003. While we do have an environment that we can use for some testing of the migration it doesn&#8217;t mimic our production environment [...]]]></description>
			<content:encoded><![CDATA[<p><em>[Part 2 of this series which involves the actual configuration of the Vyatta routers is</em><a href="http://cars.lostroncos.org/2010/02/18/a-more-interesting-environment-with-vyatta-and-vmware-pt2/"><em> now up here</em></a><em> -crt]</em></p>
<p>At work we&#8217;ve recently made the decision to migrate to Exchange 2010 from Exchange 2003. While we do have an environment that we can use for some testing of the migration it doesn&#8217;t mimic our production environment closely enough for me to be comfortable using it as the sole test area. Given the changes in how Exchange 2010 (E2KX) works vs 2003 I wanted to be able to simulate multiple (2) Active Directory sites (i.e. subnets), a DMZ, and the &#8220;Internet&#8221; including some really simple firewalls.</p>
<p>I wanted to use virtual machines to go through this exercise so that I could take snapshots and repeat the various steps and/or variations of them if necessary. In order to do this I utilized the Vyatta Community Edition based routers to help create my virtual &#8220;enterprise&#8221; environment. I&#8217;ve talked about<a href="http://cars.lostroncos.org/2008/09/18/using-vyatta-with-vmware/" target="_blank"> Vyatta before in this article</a>. In this post I&#8217;ll talk a little about the process I went through to get to my final configuration (shown below).  In subsequent articles I&#8217;ll go  through the actual router and VMware configuration process.</p>
<div id="attachment_299" class="wp-caption alignnone" style="width: 830px"><a rel="lightbox[8]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga8.png"><img class="size-large wp-image-299" title="Final Environment" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga8-1024x477.png" alt="Final Environment" width="820" height="382" /></a><p class="wp-caption-text">The final environment as laid out on two interconnected servers</p></div>My lab environment at home consists of two Dell PowerEdge servers (one a PE2850, the other a 2950 each with 8Gigs of RAM). Both servers are running ESXi 4.0. Since the 2850 can&#8217;t run 64 bit VMs I was going to install the Exchange 2003 servers and Windows 2003 DCs on it. Then I&#8217;d install VMs running Server 2008R2 on the 2950 with Exchange 2010. Both servers are connected to my home network and since I was going to be using both I wanted to have some way for VMs on each host to be able to communicate with others without necessarily having all the traffic come across my home network. Since both Dells have multiple NICs I connected them with a crossover cable ending up with something like this:</p>
<p><div class="wp-caption alignnone" style="width: 504px"><img title="A physical view" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga1.png" alt="" width="494" height="384" /><p class="wp-caption-text">Physical view of the network </p></div>
<p>In initially penciling out a plan for what I wanted to do I had nine VMs scattered across four subnets.</p>
<div class="wp-caption alignnone" style="width: 706px"><a rel="lightbox[2]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga2.png"><img title="Multi-gateway subnets" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga2.png" alt="" width="696" height="332" /></a><p class="wp-caption-text">Isolated environment with multiple gateways per subnet</p></div>Considering my limited resources and my need to keep some other unrelated VMs up and running while I&#8217;m testing, I trimmed this down to 7 by combining the Domain Controllers and Exchange 2003 servers together in the HQ and Remote subnets.</p>
<p><div class="wp-caption alignnone" style="width: 443px"><img title="Consolidating functions to reduce # of VMs" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga3.png" alt="" width="433" height="387" /><p class="wp-caption-text">Consolidating functions to reduce # of VMs</p></div>
<p>In further looking at this from a networking perspective, I was hit with the realization the initial configuration with two routers attached to the HQ and DMZ subnets would require me to manage routing on<strong><em> each individual VM</em></strong> in each of those subnets as well as on each of the routers. As an example one can look at the Exchange 2010 server in the HQ site/subnet.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga4.png" alt="" /></p>
<p><span id="more-300"></span></p>
<p>In this particular case the Exchange server would need to be able to route some traffic to the DMZ via 192.168.2.253 and other traffic to the &#8220;Remote&#8221; site via 192.168.2.254. (If the server was going to communicate directly with machines in our fake &#8220;Internet&#8221; I&#8217;d have to add yet another routing entry.) I can of course configure a default gateway when configuring the NIC, but still have to manually add a route for the other gateway. This process then has to be repeated on each machine. It then gets more complicated if I want to be able to use Terminal Services (RDP) to connect to the VMs rather than using the VM remote console because I now have to figure out how to connect the virtual routers to my home network and potentially add yet another routing entry.</p>
<p>I decided I&#8217;d rather have a single gateway on each subnet (so I only had to specify a default gateway on each VM) and then rely on the routers to do all the routing. I considered a couple of different ways to do this. One option was do something &#8220;meshy&#8221; where the router for each subnet was connected to common shared subnet.</p>
<p><a rel="lightbox[5]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga5.png"><img title="A &quot;mesh-y&quot; solution" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga5.png" alt="" width="591" height="378" /></a></p>
<p>This would have had the desired effect a single gateway for each subnet regardless of where traffic was going, but would have required 5 virtual routers which seemed a little excessive. Going in the other direction, another option was to have a single router connected to everything.</p>
<div class="wp-caption alignnone" style="width: 626px"><a rel="lightbox[6]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga6.png"><img title="Single-router solution" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga6.png" alt="" width="616" height="336" /></a><p class="wp-caption-text">Single-router solution</p></div><a rel="lightbox[6]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga6.png"><br />
</a></p>
<p>I ended up with a solution somewhere between the &#8220;mesh&#8221; and the single mongo router. It employs three routers. I decided on this partly because I wanted to keep things relatively simple especially since I was going to be enabling the firewall functionality between the DMZ and Internet (and wanting to limit the damage I could do to myself when working late at night).<br />
<a rel="lightbox[7]" href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga7.png"><br />
<img src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga7.png" alt="" width="649" height="317" /></a></p>
<p>Again, when all was said and done the environment I ended up with looks like the one below. In the next couple of entries I&#8217;ll go through the actual process of building the networking side of this.</p>
<p><div class="wp-caption alignnone" style="width: 784px"><a href="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga8.png"><img title="Physical/Logical view" src="http://cars.lostroncos.org/wp-content/uploads/2010/02/021810_0704_Simulatinga8.png" alt="" width="774" height="361" /></a><p class="wp-caption-text">Physical/Logical view</p></div>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2010/02/17/a-more-interesting-environment-with-vyatta-and-vmware/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Generating an ATOM feed from an Exchange 2007/10 calendar</title>
		<link>http://cars.lostroncos.org/2010/01/25/generating-an-atom-feed-from-an-exchange-calendar/</link>
		<comments>http://cars.lostroncos.org/2010/01/25/generating-an-atom-feed-from-an-exchange-calendar/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 06:58:43 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[ExchangeWebServices]]></category>
		<category><![CDATA[Home Lab]]></category>
		<category><![CDATA[ATOM]]></category>
		<category><![CDATA[EWS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=262</guid>
		<description><![CDATA[<p>I was in a meeting a little while back where we had a brief discussion regarding the ability to get data out of Exchange 2007/2010 from a non-Windows OS. The example thrown out was the ability to get an RSS feed from Google Calendar for use elsewhere. I&#8217;ve know about Exchange Web Services (EWS) for [...]]]></description>
			<content:encoded><![CDATA[<p>I was in a meeting a little while back where we had a brief discussion regarding the ability to get data out of Exchange 2007/2010 from a non-Windows OS. The example thrown out was the ability to get an RSS feed from Google Calendar for use elsewhere. I&#8217;ve know about Exchange Web Services (EWS) for a while and always wanted to look into using it in a project just to get some familiarity with it. With Exchange 2010 coming out this seemed like a good opportunity to try to see if I could generate an RSS feed from my calendar in a lab environment using a non-.Net language on Linux. I decided to try doing this using PHP, (incorrectly) assuming that there&#8217; be some easily discoverable examples I could download and tweak to do what I wanted.</p>
<p>I did discover some snippets and information that helped point me in the right direction, but no simple complete &#8220;here run this&#8221; kind of examples. I initially came across an article by Thomas Rabaix on using SOAP PHP and NTLM authentication (<a href="http://rabaix.net/en/articles/2008/03/13/using-soap-php-with-ntlm-authentication">http://rabaix.net/en/articles/2008/03/13/using-soap-php-with-ntlm-authentication</a> ). This code used cURL to help handle NTLM authentication to an IIS server. That then led me to an article by Erik Cederstrand <a href="http://www.howtoforge.com/talking-soap-with-exchange">http://www.howtoforge.com/talking-soap-with-exchange</a> that built on Thomas&#8217; work. Between them these two extend the PHP SOAPClient and then override some of the methods to use curl to handle the NTLM authentication that EWS uses by default. Using these examples as a starting point and some other bits of info I&#8217;ve come across I&#8217;ve been able to put together a couple of scripts that will generate an ATOM based feed using a user&#8217;s calendar. What I&#8217;ve managed to cobble together works but is not something I&#8217;d describe as robust. The solution is briefly described below. I&#8217;m hoping to follow up with a few other posts that go into a bit more detail about how all the pieces work. <em>[the code is available <a href="http://cars.lostroncos.org/wp-content/uploads/2010/01/ews-cal-rss.tar.gz"> from here </a> or from <a href="code.google.com/p/exchange-calendar-rss/">Google Code</a> ]</em></p>
<h2>The scripts in action</h2>
<p>In my example Exchange environment I&#8217;ve created a user called (imaginatively enough)<em> ctronco</em>. Opening up Outlook for the user I can see the following events on this weeks calendar.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga1.png" alt="" /></p>
<p>Turning now to the Ubuntu box where I&#8217;ve installed the PHP scripts. Firing up a browser and pointing it to the correct URL (http://192.168.1.175/ewscalendarfeed/getfeed/ctronco) I get the following results in Firefox, Internet Explorer and Opera (Chrome doesn&#8217;t appear to like feeds so I haven&#8217;t included it).</p>
<table border="0">
<tbody>
<tr>
<td style="text-align: center;"><strong>Output in Firefox</strong></td>
<td style="text-align: center;"><strong>Output in Internet Explorer</strong></td>
<td style="text-align: center;"><strong>Output in Opera</strong></td>
</tr>
<tr>
<td><a href="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga2.png" target="_blank"><img class="aligncenter size-medium wp-image-253" title="Firefox Output" src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga2-226x300.png" alt="Firefox Output" width="226" height="300" /></a></td>
<td><a href="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga3.png" target="_blank"><img class="aligncenter size-medium wp-image-254" title="Output in IE" src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga3-229x300.png" alt="Output in IE" width="229" height="300" /></a></td>
<td><a href="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga4.png" target="_blank"><img class="aligncenter size-medium wp-image-255" title="Output in Opera" src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga4-220x300.png" alt="Output in Opera" width="220" height="300" /></a></td>
</tr>
</tbody>
</table>
<p><span id="more-262"></span><br />
Clicking on the link of any of the individual entries will return a web a page with the same information about the individual appointment as well:</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga5.png" alt="" /></p>
<h2>How it works (at a high level)?</h2>
<p>Rather than keeping each user&#8217;s credentials around I decided to use a non-privileged account. This means that that account has to have <strong>Reviewer</strong> permissions for every calendar that will have a feed generated for it. Adding permissions for the account is a relatively straightforward proposition if you&#8217;re using Outlook. It can also be done via EWS for non-Outlook folks, I just haven&#8217;t gotten that piece done yet.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga6.png" alt="" /></p>
<p>The configuration file for the scripts has a list of known calendar &#8220;names&#8221; and the identifying information to retrieve the calendar from Exchange. Each accessible calendar has to have a unique name as far as the scripts are concerned. This is because each user can have more than one calendar available for generating a feed and I wanted to be able to support showing more than one per user.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga7.png" alt="" /></p>
<p>The naming convention you use will be up to you. Using the four calendars shown above in my test user&#8217;s mailbox either of the following example schemes would work for creating unique name for each of the calendars.</p>
<div>
<table border="1">
<tbody>
<tr>
<td>Original &#8220;Outlook&#8221; name</td>
<td>+1 scheme</td>
<td>descriptive</td>
</tr>
<tr>
<td>Calendar</td>
<td>ctronco</td>
<td>ctronco-calendar</td>
</tr>
<tr>
<td>Calendar2</td>
<td>ctronco1</td>
<td>ctronco-calendar2</td>
</tr>
<tr>
<td>Cal-sub-1</td>
<td>ctronco2</td>
<td>ctronco-cal-sub-1</td>
</tr>
<tr>
<td>fed</td>
<td>ctronco3</td>
<td>ctronco-fed</td>
</tr>
</tbody>
</table>
</div>
<p>In addition to the unique name the configuration file also needs to be given the unique Folder Id and Changekey values from EWS to retrieve them. These values aren&#8217;t easily accessible via Outlook (as far as I can tell)so I&#8217;ve included a web form (list_calendars.html) which will prompt for a user&#8217;s credentials and then list the calendars in their mailbox as well as the associated <strong>Folder Id</strong> and <strong>ChangeKey.</strong> Example output is shown:</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga8.png" alt="" /></p>
<p><em>If you install the package php5-cli, list_calendars.php (the script called by the html file) can also be run from a shell on the Ubuntu box by passing the username and password as parameters.</em></p>
<h2>Setting things up</h2>
<h3>Exchange</h3>
<p>The first thing I had to do was set up Windows 2008 and Exchange 2007 in my home lab (at the time I had hardware that wouldn&#8217;t support 64-bit VMs so I couldn&#8217;t do Exchange 2010). I set up a single machine as both an AD Domain Controller and an Exchange server with the HUB, CAS, and Mailbox roles on it. Based on my initial testing this will also work just fine with Exchange 2010.</p>
<h3>Ubuntu</h3>
<p>For my test PHP environment I set up another VM running Ubuntu 9.10 Server with the LAMP option chosen at installation.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga9.png" alt="" /></p>
<p>Once the OS install was complete I also had to install the<strong><em> libcurl3</em></strong> and <strong><em>php5-curl</em></strong> packages.</p>
<p>The initial version of the source code is available<a href="http://cars.lostroncos.org/wp-content/uploads/2010/01/ews-cal-rss.tar.gz"> here as a zip file</a>. In addition I&#8217;ve created a<a href="http://code.google.com/p/exchange-calendar-rss/" target="_blank"> project on Google Code </a>where the most recent versions can be retrieved as I work on it further.</p>
<p>To install it simply unzip the tar file in a location where apache (or the web server of your choice) can read the files. It will uninstall into a directory called ews-cal-rss. You&#8217;re welcome to change this to whatever you desire.</p>
<p><img src="http://cars.lostroncos.org/wp-content/uploads/2010/01/012610_0657_Generatinga10.png" alt="" /></p>
<p>In the example I&#8217;ve also changed the ownership of the directory so that it&#8217;s owned by the same login the web server runs under.</p>
<p>In the directory where the extracted files are you&#8217;ll find cfg_options.php. This contains almost all the configurable values. The following values need to be defined:</p>
<ul>
<li>$cfg_option['user'] &#8211; Login Id of the non-privileged account that will used to read all the calendars</li>
<li>$cfg_option[''] -</li>
<li>$cfg_option['authmethod'] &#8211; the scripts support both Basic and NTLM authentication when talking to EWS. NTLM required installation of curl</li>
<li>$cfg_option['wsdl'] &#8211; path to the appropriate Exchange Web Services WSDL file.</li>
<li>$cfg_option['installpath'] &#8211; full path to the scripts</li>
<li>$cfg_option['urlpath'] &#8211; URL for the scripts. If the script URL is http://host/ews-cal-rss/getfeed.php this would be &#8220;/ews-cal-rss&#8221;</li>
<li>You also need to populate the variable $PFIDs using the list_calendars.html file as shown above.</li>
</ul>
<p>In addition you need to modify the appropriate WSDL file for your environment. WSDL files are included for both Exchange 2007 and 2010. They are in<em><strong> &lt;installdir&gt;/e2k7_wsdl</strong></em> or <strong><em>&lt;installdir&gt;/e2kx_wsdl</em></strong> respectively. The services.wsdl needs to be modified to point to your Exchange server. At the end of the services.wsdl file you&#8217;ll find the following:</p>
<div class="codecolorer-container xml blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:operation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:binding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wsdl:service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ExchangeServices&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wsdl:port</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ExchangeServicePort&quot;</span> <span style="color: #000066;">binding</span>=<span style="color: #ff0000;">&quot;tns:ExchangeServiceBinding&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;soap:address</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;https://exchange.company.com/EWS/Exchange.asmx&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:definitions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>You need to modify the soap:address entry to point to your Exchange server. In my case that would be</p>
<div class="codecolorer-container xml blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:operation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:binding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wsdl:service</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ExchangeServices&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wsdl:port</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ExchangeServicePort&quot;</span> <span style="color: #000066;">binding</span>=<span style="color: #ff0000;">&quot;tns:ExchangeServiceBinding&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;soap:address</span> <span style="color: #000066;">location</span>=<span style="color: #ff0000;">&quot;https://e2k7.exchange.lostroncos.org/EWS/Exchange.asmx&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wsdl:definitions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<h2>A few miscellaneous notes:</h2>
<ul>
<li>It is also possible to use calendars in a public folder to generate the feeds. However listing them is slightly more involved than it is for a users calendars.</li>
</ul>
<ul>
<li>Re: the use of NTLM. It is also possible to modify the Exchange server&#8217;s web server configuration to enable the use of &#8216;Basic&#8217; authentication in addition to NTLM. Since by default communication with the Exchange server takes place over HTTPS this may or may not be acceptable in your environment. Using basic authentication gets you out of having to install the cURL bits, but may or may not be acceptable from a security perspective depending on your environment.</li>
<li>This is a test to see if this works better than the 32 bit version of IE does in full screen visual mode with wordpress&#8230;.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2010/01/25/generating-an-atom-feed-from-an-exchange-calendar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A less simple (but better) Replay Report</title>
		<link>http://cars.lostroncos.org/2009/10/12/a-less-simple-but-better-replay-report/</link>
		<comments>http://cars.lostroncos.org/2009/10/12/a-less-simple-but-better-replay-report/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 08:23:41 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[appassure]]></category>
		<category><![CDATA[charting]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google chart api]]></category>
		<category><![CDATA[recovery point]]></category>
		<category><![CDATA[Replay]]></category>
		<category><![CDATA[snapshot]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=220</guid>
		<description><![CDATA[<p>A while back I posted about a Replay report that I wrote to help me monitor the multiple Replay servers we have deployed globally.  It was a good first effort and was useful, but having to engage my brain first thing in the morning to read (and more importantly actually comprehend) the emailed reports eofre [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I posted about a <a href="http://cars.lostroncos.org/2009/04/30/a-simple-replay-report/" target="_blank">Replay report that I wrote</a> to help me monitor the multiple Replay servers we have deployed globally.  It was a good first effort and was useful, but having to engage my brain first thing in the morning to read (and more importantly actually comprehend) the emailed reports eofre my second cup of coffee was less than ideal.</p>
<p>Thwe original idea behind generating the report was to have the info come to me rather than logging into multiple servers and firing up the console multiple times (what can I say I&#8217;m lazy).</p>
<p>The report in the first version of the script was straighforward text. Recently I&#8217;ve been looking into and thinking about different ways to present the information in the report so I could just sort of glance at it and get the status. The disk related portion of the report wasn&#8217;t initially where I was focusing my attention. I was more interested in being able to get a quick idea of where we stood with the # of Recovery Points we were expecting to have.  An example of  one of the simple reports is below. From this we can see that we&#8217;re in pretty good shape with 100% valid RPs spanning about 24 days.</p>
<p style="padding-left: 60px;">Starting Script at 04/30/2009 23:20:12</p>
<p style="padding-left: 60px;">Replay Service is running</p>
<p style="padding-left: 60px;">Server <strong><em>mailserver.company.com</em></strong> snapshots are being stored on R: and currently using 818.54GB. This is 99.98% of the used space(818.68GB) on the volume which is 1,360.22GB</p>
<p style="padding-left: 60px;">The drive currently has 39.81% free space (e.g. 541.54GB)</p>
<p style="padding-left: 60px;">Number of reported Recovery Points is 395 of these 395 are valid, and 0 are invalid (100.00%).<br />
The valid RPs span 23.98 days</p>
<p style="padding-left: 60px;">The most recent valid RP was taken 1 Minutes ago</p>
<p>The issue becomes less clear when invalid RPs occur for whatever reason. If I have 395 RPs and only 250 of the are valid is that a good or bad state? It&#8217;s not immediately clear but one can log in to the Replay server and get a better idea of how things stand. It might be the case where there was network issue during the day and instead of 96 RPs  (that&#8217;s an RP every 15 minutes * 24 hrs) for each of the last three days we&#8217;ve only gotten 40 RPs each of those days which while less than ideal might still be an okay state. Or it could be that there are several days for which we don&#8217;t have RPs.</p>
<p><span id="more-220"></span></p>
<p>I was trying to think of a way to visualize this information. Because of the retention schedule some days we&#8217;d expect a large number of RPs (~90) and some other days we&#8217;d expect to have just one.  I looked into the possibility of using sparklines even going so far as to download a <a href="http://ewbi.blogs.com/develops/2005/07/sparklines.html">C# based version</a> of  a<a href="http://sparklines.bitworking.info/"> PHP based sparkline web service</a> from Joe Gregorio.</p>
<p>I tried several different iterations of the script using sparklines trying to use the data I had in different ways (ex: use percentages of expected RPs, diffs between expected and actaul) but wasn&#8217;t able to find a good way to represent the state using those. In digging around I came across the Google Chart API and that looked at bar different ways of using bar graphs to represent the info I wanted.  Using either side-by-side bar graphs</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_bar_sidebyside.png"><img class="alignright size-full wp-image-224" title="replay_report_rps_ex_bar_sidebyside" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_bar_sidebyside.png" alt="replay_report_rps_ex_bar_sidebyside" width="634" height="275" /></a></p>
<p>overlapping ones with green and red where a lot of red would be a bad thing.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_bar_overlay.png"><img class="aligncenter size-full wp-image-223" title="replay_report_rps_ex_bar_overlay" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_bar_overlay.png" alt="replay_report_rps_ex_bar_overlay" width="662" height="277" /></a></p>
<p>Either of these would have been an improvement over what I was getting in the text based report.  While trying to refine the overlaid version I came across an example in the Google <a href="http://code.google.com/apis/chart/styles.html#line_styles">documentation on line style</a>s of  this graph:</p>
<div class="wp-caption alignnone" style="width: 210px"><img title="Chart Data Line example from Google Chart API" src="http://chart.apis.google.com/chart?cht=bvg&amp;chbh=5,2&amp;chm=D,0033FF,1,0,5,1&amp;chbh=20&amp;chs=200x150&amp;chd=s1:1XQbnf4,43ksfg6&amp;chco=76A4FB" alt="Chart Data Line example from Google Chart API" width="200" height="150" /><p class="wp-caption-text">Chart Data Line example from Google Chart API</p></div>
<p>This caught my eye as a possible solution to my problem about how to present this data because of the ability to show both sets of data overlaid on each other while still managing to keep both of them visible.</p>
<p>In my particular scenario the retention schedule is:</p>
<ul>
<li>RPs every 15  minutes which are kept for 4 days</li>
<li>These roll up to hourly RPs which are kept for 5 days</li>
<li>Hourly&#8217;s roll up to dailies which are kept for ~25 days</li>
</ul>
<p>Our goal is to keep about 30 <strong><em>consecutive</em></strong> days worth of RPs on hand. When plotting out the # of expected RPs per day we get a graph that looks like the one below.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_bar_solo.png"><img class="aligncenter size-full wp-image-228" title="replay_report_rps_ex_bar_solo" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_bar_solo.png" alt="replay_report_rps_ex_bar_solo" width="624" height="266" /></a></p>
<p>As one can see the number of Recovery Points per day decreases over time. When adding the line showing the number of actual RPs it can be hard to tell what the status is for the days where there&#8217;s only one RP per day. If things are going well the green bars will be obscured by the red line.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_ideal.png"><br />
<img class="aligncenter size-full wp-image-218" title="replay_report_rps_ex_ideal" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_ideal.png" alt="replay_report_rps_ex_ideal" width="640" height="278" /></a></p>
<p>In the rare instance where we might be missing a few daily RPs the green bars do become somewhat visible as shown in the blue box below.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily.png"><img class="aligncenter size-full wp-image-232" title="replay_report_rps_ex_missing_daily" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily.png" alt="replay_report_rps_ex_missing_daily" width="600" height="250" /></a></p>
<p>I experimented with a couple of different ways to try to make this more obvious including altering the width and height of the chart to make it more obvious. (see below). Using the Google Chart API one is limited to an image with 300000 pixels (500&#215;600)</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily_tall.png"><img class="aligncenter size-full wp-image-233" title="replay_report_rps_ex_missing_daily_tall" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily_tall.png" alt="replay_report_rps_ex_missing_daily_tall" width="526" height="626" /></a><a title="Tall Graph" href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily_tall.png" target="_blank"><br />
</a></p>
<p>But for me persoanlly making the chart a lot bigger like  this seemed like it didn&#8217;t really add all that much to being able to see what was going on.  So I stuck with 600&#215;250 for the graph.</p>
<p>It should also be noted that in the case where you aren&#8217;t taking snapshots every 15 minutes but evey 30 minutes or maybe even every hour it becomes easier to see missed daily RPs.  Here&#8217;s an example</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily_50.png"><img class="aligncenter size-full wp-image-234" title="replay_report_rps_ex_missing_daily_50" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_rps_ex_missing_daily_50.png" alt="replay_report_rps_ex_missing_daily_50" width="627" height="276" /></a></p>
<p>After going through all of this with the RPs I almost as an afterhtought went back and added the logic to graph the disk usage data as well. It shows the size of the Replay archive data, the free space and other used space on the drive by generating something like this:</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_disk_usage.png"><img class="aligncenter size-full wp-image-235" title="replay_report_disk_usage" src="http://cars.lostroncos.org/wp-content/uploads/2009/10/replay_report_disk_usage.png" alt="replay_report_disk_usage" width="366" height="217" /></a></p>
<p>Here&#8217;s a <a title="Example Replay Report" href="http://cars.lostroncos.org/wp-content/uploads/2009/10/example_replay_report.png" target="_blank">&#8220;real-life&#8221;  example of the whole report</a>.</p>
<p>The <a href="http://cars.lostroncos.org/wp-content/uploads/2009/10/Replay_Report_v2-01.txt" target="_blank">script is available here</a>. If it&#8217;s of any use to you please drop me a line and let me know.</p>
<p>To use it rename it to something like ReplayReport.ps1. You&#8217;ll need to modify the variables at the beginning of the file:</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>$ReportRecipients &#8211; array of recipient email addresses.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>$MailServer &#8211; The SMTP server to use to send the report out</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>$ReportSender -Address the email should appear to come from.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>$replay_exe &#8211; Path to the Replayc.exe file. May differ on x64 vs x86</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span> servers.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>$ExpectedRPCount &#8211; array containing the number of expected RPs for the</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span> last X days. Used to generate the graph of expected vs</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span> present RPs. (See Note below)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">The script doesn&#8217;t take any arguments to run. I run it via a scheduled task</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">on the replay server.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">***************</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">In reference to $ExpectedRPCount the time of day that the report is run will</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">affect how the first data point on the graph appears. RPs are tracked by the</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">date that they were taken. If you run the script just before midnight there</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3491px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">will obviously be a lot more RPs for &#8220;today&#8221; than if you run it at 1 am.</div>
<ul>
<li>$ReportRecipients &#8211; array of recipient email addresses.</li>
<li>$MailServer &#8211; The SMTP server to use to send the report out</li>
<li>$ReportSender -Address the email should appear to come from.</li>
<li>$replay_exe &#8211; Path to the Replayc.exe file. May differ on x64 vs x86  servers.</li>
<li>$ExpectedRPCount &#8211; array containing the number of expected RPs for the last X days. Used to generate the graph of expected vs present RPs. (See Note below)</li>
</ul>
<p>The script doesn&#8217;t take any arguments to run. I run it via a scheduled task on the replay server.</p>
<p>***************</p>
<p><em>In reference to $ExpectedRPCount the time of day that the report is run will affect how the first data point on the graph appears. RPs are tracked by the date that they were taken. If you run the script just before midnight there will obviously be a lot more RPs for &#8220;today&#8221; than if you run it at 1 am.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2009/10/12/a-less-simple-but-better-replay-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios ESXi scripts work with the vSphere SDK</title>
		<link>http://cars.lostroncos.org/2009/07/17/nagios-esxi-scripts-work-with-the-vsphere-sdk/</link>
		<comments>http://cars.lostroncos.org/2009/07/17/nagios-esxi-scripts-work-with-the-vsphere-sdk/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 23:21:13 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=199</guid>
		<description><![CDATA[<p>I&#8217;ve gotten a couple of emails recently about issues with the Nagios plugins I&#8217;ve got here. The people having issues appeared to be using really early versions of the VI-Perl toolkit from VMware. In looking for the URL to download the more recent versions of the toolkit (v1.5 and 1.6) I kept ending up at [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten a couple of emails recently about issues with the <a href="http://cars.lostroncos.org/2008/03/07/updated-esx-3i-scripts-for-nagios/">Nagios plugins I&#8217;ve got here</a>. The people having issues appeared to be using really early versions of the VI-Perl toolkit from VMware. In looking for the URL to download the more recent versions of the toolkit (v1.5 and 1.6) I kept ending up at the link for the vSphere SDK.  After going round and round for a while I ended up downloading the SDK to see if the scripts work with it. I&#8217;m relieved to report that based on my testing they work just fine. Getting the SDK installed and running was a bit of an issue but once that was done they worked fine.</p>
<p>I also finally found the URL for the downloads to the other versions of the VI-perl stuff as well at : <a href="http://communities.vmware.com/community/developer/vsphere_sdk_perl">http://communities.vmware.com/community/developer/vsphere_sdk_perl</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2009/07/17/nagios-esxi-scripts-work-with-the-vsphere-sdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios ESX3i Scripts and ESX4i</title>
		<link>http://cars.lostroncos.org/2009/06/29/nagios-esx3i-scripts-and-esx4i/</link>
		<comments>http://cars.lostroncos.org/2009/06/29/nagios-esx3i-scripts-and-esx4i/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 22:57:09 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[NAgios]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[3i]]></category>
		<category><![CDATA[4i]]></category>
		<category><![CDATA[ESX]]></category>
		<category><![CDATA[esx3i]]></category>
		<category><![CDATA[esx4i]]></category>
		<category><![CDATA[esxi]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=193</guid>
		<description><![CDATA[<p>This is just an update, but the scripts I wrote for use with Nagios and ESX3i seem to work just fine with ESX4i (at least in my home lab environment using Dell Poweredge 2850s).</p>
]]></description>
			<content:encoded><![CDATA[<p>This is just an update, but the <a href="http://cars.lostroncos.org/2008/03/07/updated-esx-3i-scripts-for-nagios/">scripts I wrote for use with Nagios and ESX3i</a> seem to work just fine with ESX4i (at least in my home lab environment using Dell Poweredge 2850s).</p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2009/06/29/nagios-esx3i-scripts-and-esx4i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Neverfail monitoring with Zabbix part 1</title>
		<link>http://cars.lostroncos.org/2009/05/31/simple-monitoring-of-neverfail-with-zabbix-part-1/</link>
		<comments>http://cars.lostroncos.org/2009/05/31/simple-monitoring-of-neverfail-with-zabbix-part-1/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 05:01:54 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[neverfail]]></category>
		<category><![CDATA[zabbix]]></category>
		<category><![CDATA[neverfail for Exchange]]></category>
		<category><![CDATA[neverfail heartbeat]]></category>
		<category><![CDATA[reg_dword_big_endian]]></category>
		<category><![CDATA[windows registry]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=157</guid>
		<description><![CDATA[Background
<p>This is the first of a couple of posts on how I&#8217;ve cobbled together some basic monitoring of Neverfail&#8217;s  Neverfail Heartbeat H/A software which is also now the basis for VMWare&#8217;s vCenter Server Heartbeat. Since Neverfail seems to consider their command lines privileged information I will only cover how to do some simple monitoring using [...]]]></description>
			<content:encoded><![CDATA[<h2>Background</h2>
<p>This is the first of a couple of posts on how I&#8217;ve cobbled together some basic monitoring of <a href="http://www.neverfailgroup.com/">Neverfail&#8217;s  Neverfail Heartbeat H/A</a> software which is also now the basis for <a href="http://www.vmware.com/products/vcenter-server-heartbeat/">VMWare&#8217;s vCenter Server Heartbeat</a>. Since Neverfail seems to consider their command lines privileged information I will only cover how to do some simple monitoring using the registry. When starting on this effort internally I was only interested initially in figuring out a quick and simple way to get the info I needed and not so much on the how to get it into something part.</p>
<p>I&#8217;ve been working with another team where I work to look at Zabbix as an alternative for some of the monitoring we do in our environment. We use Microsoft Operations Manager 2005 (MOM) but haven&#8217;t fully cut over from out previous monitoring solution. I had looked at Zabbix earlier as a potential solution for monitoring a bunch of VMware ESX boxes but another team ended up getting tasked with that particular duty. So I had had some experience with Zabbix but hadn&#8217;t done too much with it since.</p>
<p>One of the things that&#8217;d been rattling around in my brain is using the capabilities of using the zabbix_sender feature/client to monitor some of other components/things we can&#8217;t easily get into MOM.  Zabbix_Sender is a utility that is available for use with Zabbix that allows one to &#8220;send&#8221; information to Zabbix. In my case it was appealing because we&#8217;re already running two different monitoring agents on the Exchange servers where we have Neverfail installed.  Since I only wanted to use Zabbix to monitor a small set of data related specifically to Neverfail zabbix_sender lets me do that without having to run the fullblown zabbix_agent as a service on the boxes.</p>
<p><span id="more-157"></span></p>
<h2>Getting the Data</h2>
<p>Neverfail (at least the versions we have installed) doesn&#8217;t obviously expose performance data. However if you look in the registry on each Neverfail server you will find some registry values (see <strong><em>HKLM\Software\Neverfail\R2\Performance</em></strong>) that get updated on a regular and frequent basis that correspond to data presented in the Neverfail GUI . Because of the way Neverfail works some of this data (Unsafe Queue info) is available on the Active node and some of it (Safe Queue info) is in the registry on the Passive node. This presents a couple of issues when trying to put together the solution (at least in my environment).</p>
<p>The first of these is trying to find a single consistent way to get the data out of the registry, especially since all the counters involved are of the REG_DWORD_BIG_ENDIAN variety (you can see a <a href="http://cars.lostroncos.org/2009/03/09/big_endian-registry-values/">previous entry related to BIG_ENDIAN here</a>).  I ended up settling on using the Reg.exe util available in Windows.  This utility let&#8217;s you manipulate the registry locally and remotely. While it doesn&#8217;t necessarily deal happily with REG_DWORD_BIG_ENDIAN (RDBE) entries in the registry it is able to extract the data which we can then manipulate to get the correct values.</p>
<p>As an example if I have the following two values in the registry as shown by RegEdit</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_example_01.png"><img class="alignnone size-full wp-image-159" title="reg_example_01" src="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_example_01.png" alt="reg_example_01" width="462" height="166" /></a></p>
<p>When I run <strong><em>reg.exe</em></strong> I get the following output&#8230;</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_query_rdword_rdbe.png"><img class="alignnone size-full wp-image-160" title="reg_query_rdword_rdbe" src="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_query_rdword_rdbe.png" alt="reg_query_rdword_rdbe" width="576" height="129" /></a></p>
<p>So while Dword_example and DWORD_BE_Example nominally have the same value <strong><em>reg.exe</em></strong> doesn&#8217;t get the data out correctly for the latter. However as I said earlier once we have the data out we can actually do some magic to get the right value.</p>
<p>We can also use <strong><em>reg.exe</em></strong> to get values on a remote machine (i.e. our Passive Neverfail node) by pre-pending the host info to the query registry path. So in this case to reach the passive secondary node over the private channel at 10.0.0.2 I can do something like  reg.exe Query \\10.0.0.2\CRT_CORP\Performance. Testing this out leads us to  a second issue. Getting an  &#8221;Acces is denied&#8221; error.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_error_access_denied.png"><img class="alignnone size-full wp-image-158" title="reg_error_access_denied" src="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_error_access_denied.png" alt="reg_error_access_denied" width="592" height="176" /></a></p>
<p>Since my passive Neverfail node is essentially off-net but still thinks the network cables is live I can&#8217;t use a domain based account to run the reg.exe command because it can&#8217;t contact a domain controller to authenticate my domain account. However if I use the local Administrator account which has a common password on both nodes I can get this work just fine. (It may be possible to use an account other than the local Administrator but in my case where I also run some Neverfail command lines I need an account that&#8217;s authorized in Neverfail)</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_remote_as_admin.png"><img class="alignnone size-full wp-image-161" title="reg_remote_as_admin" src="http://cars.lostroncos.org/wp-content/uploads/2009/05/reg_remote_as_admin.png" alt="reg_remote_as_admin" width="528" height="188" /></a></p>
<p>Given this info I was able to put together a<a href="http://cars.lostroncos.org/?attachment_id=168"> </a><a href="http://cars.lostroncos.org/?attachment_id=172">vbscript that takes two arguments</a>: a reg path and a value name;  and it returns the data value to the console converting REG_DWORD and REG_DWORD_BIG_ENDIAN to the correct decimal value. Using <a href="http://cars.lostroncos.org/wp-content/uploads/2009/06/getregvaluevbs.txt">this script</a> it&#8217;s then possible to get  any of the counters we&#8217;re interested in on either the active or passive node.  So based on the example above where I ran <em>reg.exe hklm\software\CRT_CORP\Performance /s</em> we can run the script for each of the values and see that we do in fact get the right decimal value for each one.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/06/getregvalue_example_01.png"><img class="alignnone size-full wp-image-176" title="getregvalue_example_01" src="http://cars.lostroncos.org/wp-content/uploads/2009/06/getregvalue_example_01.png" alt="getregvalue_example_01" width="702" height="213" /></a></p>
<p>So now the trick is to figure out which of the registry based perf values we want to use and which host we need to draw them from.  Each of the Neverfail nodes has the same set of values present even though they&#8217;re not all populated the same way. That is to say that the counters related to the Safe Queue are not updated on the Active node since the Safe Queue exists on the passive node. And the converse is true with regard to the UnsafeQueue counters.  As I was mostly interested in alerting related to an issue we have occur occassionally I really wanted to get the SafeQueue and UnsafeQueue related counters (OldestSafeUpdateQueueEntry, SafeUpdateQueueSize etc). But since the other counters are also equally easy to get I decided I to include several more.  The image below shows the available values.</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/05/nf_perf_reg_values.png"><img class="alignnone size-full wp-image-164" title="nf_perf_reg_values" src="http://cars.lostroncos.org/wp-content/uploads/2009/05/nf_perf_reg_values.png" alt="nf_perf_reg_values" width="481" height="337" /></a></p>
<p>So now that I have a simple way of getting the information I want I can focus on how to get it into whatever system I want to monitor with whether it&#8217;s Zabbix (now) or Systems Center Operations Manager 2007 (later).  In the next article(s) I&#8217;ll talk about setting up the Zabbix part of this monitoring.</p>
<p><strong><em>Acknowledgement: The hex to decimal routine in the GetRegValue.vbs script is lifted directly from </em></strong><strong><em><a href="http://www.sonofsofaman.com/hobbies/code/hextodec.asp">http://www.sonofsofaman.com/hobbies/code/hextodec.asp</a> Thanks to Joel for keeping me from having to reinvent the wheel. -crt</em></strong></p>
<p><strong>Addendum</strong>: While traipsing through the registry in figuring this stuff out I also discovered that there&#8217;s a bunch of configuration information stored in a whole different key under HKLM\Software\Javasoft\Prefs\neverfail\current\* It&#8217;s also possible to watch a few entries here to help monitor the  file and registry synchronization status even though it&#8217;s not as granular/descriptive/timely as can be obtained by using the command line.</p>
<p>The two items I&#8217;ve found that might be of interest are the <strong>/Registry/State/Manager\/Statu</strong>s Key and the <strong>/Value</strong> entry</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/06/reg_java_prefs_reg.png"><img class="alignnone size-full wp-image-183" title="reg_java_prefs_reg" src="http://cars.lostroncos.org/wp-content/uploads/2009/06/reg_java_prefs_reg.png" alt="reg_java_prefs_reg" width="725" height="212" /></a></p>
<p>and  the <strong>/New/File/State/Mgr\/Synchronization/Status</strong> key and <strong>/Tag</strong> entry</p>
<p><a href="http://cars.lostroncos.org/wp-content/uploads/2009/06/reg_java_prefs_file.png"><img class="alignnone size-full wp-image-182" title="reg_java_prefs_file" src="http://cars.lostroncos.org/wp-content/uploads/2009/06/reg_java_prefs_file.png" alt="reg_java_prefs_file" width="713" height="221" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2009/05/31/simple-monitoring-of-neverfail-with-zabbix-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Simple Replay Report</title>
		<link>http://cars.lostroncos.org/2009/04/30/a-simple-replay-report/</link>
		<comments>http://cars.lostroncos.org/2009/04/30/a-simple-replay-report/#comments</comments>
		<pubDate>Fri, 01 May 2009 06:08:41 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[Replay]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=122</guid>
		<description><![CDATA[<p>Where I work we use AppAssure&#8217;s Replay product to back up some of our Exchange servers.  Because the servers in question are very geographically dispersed we have multiple servers running Replay.  Monitoring and keeping an eye on them to assure backups are happening properly was requiring more time than I wanted to spend because we [...]]]></description>
			<content:encoded><![CDATA[<p>Where I work we use AppAssure&#8217;s Replay product to back up some of our Exchange servers.  Because the servers in question are very geographically dispersed we have multiple servers running Replay.  Monitoring and keeping an eye on them to assure backups are happening properly was requiring more time than I wanted to spend because we had different versions of Replay running in the environment. I ended up having to RDP to multiple machines on a regular basis to ensure things were going smoothly.</p>
<p>In poking around the install directory I came across the <a href="https://support.appassure.com/ics/support/KBAnswer.asp?questionID=119" target="_blank">Replayc.exe command</a>. Replayc is a command line utilty that offers information about the Replay server and a way to manually mount and dismount Recovery Points (RPs). After playing with it a little and being the very lazy person that I am  I decided to write a Powershell script to help give me a high level status overview of my servers.  The script runs on each server at about the same time (relative to me here in Oregon) every day and emails me the output. So instead of having to muck around in the console Ionly have to spend a few seconds each to make sure everything&#8217;s running properly.</p>
<p>The <a href="http://cars.lostroncos.org/?attachment_id=145">script is available here</a> and needs to be renamed appropriately.</p>
<p>When the script runs the email (HTML formatted)  I get is like the one below.  It tells me a number of things:</p>
<ul>
<li>The status of the Replay Server (running/not running)</li>
<li>The name of the server that&#8217;s being protected</li>
<li>How much disk space is available and being used for RPs for that protected server</li>
<li>The size of the disk where those RPs are being stored</li>
<li>The # of valid and invalid RPs</li>
<li>The timespan between first and last valid RP</li>
<li>Last time an RP occurred.</li>
</ul>
<p>Example Email:</p>
<p style="padding-left: 60px;">Starting Script at 04/30/2009 23:20:12</p>
<p style="padding-left: 60px;">Replay Service is running</p>
<p style="padding-left: 60px;">Server <strong><em>mailserver.company.com</em></strong> snapshots are being stored on R: and currently using 818.54GB. This is 99.98% of the used space(818.68GB) on the volume which is 1,360.22GB</p>
<p style="padding-left: 60px;">The drive currently has 39.81% free space (e.g. 541.54GB)</p>
<p style="padding-left: 60px;">Number of reported Recovery Points is 395 of these 395 are valid, and 0 are invalid (100.00%).<br />
The valid RPs span 23.98 days</p>
<p style="padding-left: 60px;">The most recent valid RP was taken 1 Minutes ago</p>
<p style="padding-left: 60px;"> </p>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2009/04/30/a-simple-replay-report/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Big_Endian values in the Windows Registry</title>
		<link>http://cars.lostroncos.org/2009/03/09/big_endian-registry-values/</link>
		<comments>http://cars.lostroncos.org/2009/03/09/big_endian-registry-values/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 23:41:07 +0000</pubDate>
		<dc:creator>cars</dc:creator>
				<category><![CDATA[monitoring]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[reg_dword_big_endian]]></category>
		<category><![CDATA[windows registry]]></category>

		<guid isPermaLink="false">http://cars.lostroncos.org/?p=97</guid>
		<description><![CDATA[<p>I was working today on trying to write some scripts to help me better monitor our various installations of Neverfail.  The command line tools they provide don&#8217;t provide all the performance information I need but (strangely enough) they do write some of it into the Registry where it gets updated very frequently.  In [...]]]></description>
			<content:encoded><![CDATA[<p>I was working today on trying to write some scripts to help me better monitor our various installations of Neverfail.  The command line tools they provide don&#8217;t provide all the performance information I need but (strangely enough) they do write some of it into the Registry where it gets updated very frequently.  In writing a Powershell script to read these values I was having issues with a set of the values I was reading.  Some values would be handled correctly and others were returning weird results. Below is an example of the &#8220;weird&#8221; ones.</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">PS</span> C:\Users\cars<span style="color: pink;">&gt;</span> <span style="color: #800080;">$badKey</span><span style="color: pink;">=</span><span style="color: #008080; font-weight: bold;">Get-Item</span> <span style="color: #800000;">&quot;HKLM:\Software\CRTCORP\Product_B&quot;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\Users\cars<span style="color: pink;">&gt;</span> <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$value</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$badKey</span>.GetValueNames<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
<span style="color: pink;">&gt;&gt;</span> <span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;$value | &quot;</span> <span style="color: #008080; font-style: italic;">-nonewline</span><br />
<span style="color: pink;">&gt;&gt;</span>Write<span style="color: pink;">-</span>Host <span style="color: #800080;">$badKey</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;$value&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: pink;">&gt;&gt;</span> <span style="color: #000000;">&#125;</span><br />
<span style="color: pink;">&gt;&gt;</span><br />
PerfCtr1 <span style="color: pink;">|</span> 0 0 0 0<br />
PerfCtr2 <span style="color: pink;">|</span> 0 13 136 8<br />
PerfCtr3 <span style="color: pink;">|</span> 0 0 3 101<br />
<br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\Users\cars<span style="color: pink;">&gt;</span> <span style="color: #800080;">$example</span><span style="color: pink;">=</span><span style="color: #800080;">$badKey</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;PerfCtr1&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\Users\cars<span style="color: pink;">&gt;</span> <span style="color: #800080;">$example</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">gm</span><br />
<br />
TypeName: System.Byte<br />
<br />
Name MemberType Definition<br />
<span style="color: pink;">----</span> <span style="color: pink;">----------</span> <span style="color: pink;">----------</span><br />
CompareTo Method System.Int32 CompareTo<span style="color: #000000;">&#40;</span>Object value<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> System.Int32 CompareTo<span style="color: #000000;">&#40;</span>Byte value<span style="color: #000000;">&#41;</span><br />
Equals Method System.Boolean Equals<span style="color: #000000;">&#40;</span>Object obj<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> System.Boolean Equals<span style="color: #000000;">&#40;</span>Byte obj<span style="color: #000000;">&#41;</span><br />
GetHashCode Method System.Int32 GetHashCode<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
GetType Method System.<span style="color: #008080; font-weight: bold;">Type</span> GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
GetTypeCode Method System.TypeCode GetTypeCode<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
ToString Method System.String ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> System.String ToString<span style="color: #000000;">&#40;</span>String format<span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> System.String ...</div></div>
<p>So what it it turns out I was getting from the GetValue method was a sequence of 4 bytes as an array.  This made me wonder what the heck was going on so I fired up RegEdit to take a look.  The contents of the Data column looked okay but the Type was different, so I expanded the column to see what was different and discovered REG_DWORD_BIG_ENDIAN as a type. This was one I don&#8217;t recall having seen before.</p>
<p>TechNet has the following to say about DWORD and it&#8217;s brethren:</p>
<p>REG_DWORD<br />
A 32-bit (4-byte) number. Boolean (&#8221;True&#8221; or &#8220;False&#8221;) values and many entries for device drivers and services use this data type. REG_DWORD data can be displayed and entered in hexadecimal or decimal format in the registry editor Regedit.exe. For an example, see the ActivityLogFlag entry.</p>
<p>REG_DWORD_BIG_ENDIAN<br />
Same as REG_DWORD. A 32-bit number in which the most significant byte is displayed as the leftmost (or high-order) byte. This is the most common format for storing numbers in computers that are running Windows Server 2003.</p>
<p>REG_DWORD_LITTLE_ENDIAN<br />
A 32-bit number in which the most significant byte is displayed as the rightmost (or low-order) byte. This is opposite of the order in which bytes are stored in the REG_DWORD and REG_DWORD_BIG_ENDIAN data types.</p>
<p>If you&#8217;re not paying attention it could be easy to miss the difference when using RegEedit since they appear almost identical to DWORD values.  The only obvious difference is the &#8220;Type&#8221; field.</p>
<p>So in the example above GetValue returns different values for &#8220;PerfCtr2&#8243; and &#8220;PerfCtr2 DWORD&#8221; which are nominally the same value (at least according to RegEdit).</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>Write<span style="color: pink;">-</span>Host <span style="color: #800080;">$key</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;PerfCtr2&quot;</span><span style="color: #000000;">&#41;</span><br />
0 13 136 8<br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>Write<span style="color: pink;">-</span>Host <span style="color: #800080;">$key</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;PerfCtr2 DWORD&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #804000;">886792</span></div></div>
<p>To help me figure out how to get the info I was looking for I put together a test and created a couple of dummy registry keys with each of the types of reg keys and some examples.</p>
<p>If we try to see what Powershell tells us about each of these keys we see that for our BIG_ENDIAN friend GetValueKind returns &#8220;unknown.&#8221;</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$key1</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Item</span> <span style="color: #800000;">&quot;HKLM:\Software\CRTCORP\Product_A&quot;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>foreach <span style="color: #000000;">&#40;</span><span style="color: #800080;">$value</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$key1</span>.GetValueNames<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$value</span> <span style="color: #800000;">&quot; | &quot;</span> <span style="color: #800080;">$key1</span>.GetValueKind<span style="color: #000000;">&#40;</span><span style="color: #800080;">$value</span><span style="color: #000000;">&#41;</span> <span style="color: #800000;">&quot;|&quot;</span> <span style="color: #800080;">$key1</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800080;">$value</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><br />
REG_SZ Example <span style="color: pink;">|</span> String <span style="color: pink;">|</span> This is a test of the emergency broadcast system<br />
REG_DWORD Example <span style="color: pink;">|</span> DWord <span style="color: pink;">|</span> 1<br />
REG_MULTI_SZ Example <span style="color: pink;">|</span> MultiString <span style="color: pink;">|</span> This is a test This is another Test<br />
REG_EXPAND_SZ <span style="color: pink;">|</span> ExpandString <span style="color: pink;">|</span> C:\ProgramData\Fred<br />
REG_DWORD_BIG_ENDIAN <span style="color: pink;">|</span> Unknown <span style="color: pink;">|</span> 161 178 195 212<br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span></div></div>
<p>GetValue converts each byte to a decimal value. Our key REG_DWORD_BIG_ENDIAN (0xa1b2c3d4) can be expressed as 4 bytes &#8220;a1&#8243; &#8220;b2&#8243; &#8220;c3&#8243; &#8220;d4&#8243; which when converted become the values &#8220;161&#8243; &#8220;178&#8243; &#8220;195&#8243; &#8220;212&#8243;. While this is mildly useful it doesn&#8217;t help us easily get the value we want 2712847316.   While it is possible to get the right value by doing some math [ (byte1 * 256^3) + (byte2 * 256^2) + (byte3 * 256) + byte4 ] I thought my resulting attempts to write a snippet to do this were ugly since it doesn&#8217;t appear Powershell has any easy way to do exponentiation.</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$key</span><span style="color: pink;">=</span><span style="color: #008080; font-weight: bold;">Get-Item</span> <span style="color: #800000;">&quot;HKLM:\Software\CRTCorp\Product_A&quot;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$bytes</span><span style="color: pink;">=</span> <span style="color: #800080;">$key</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;REG_DWORD_BIG_ENDIAN&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$number</span><span style="color: pink;">=</span>0<br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>for <span style="color: #000000;">&#40;</span><span style="color: #800080;">$idx</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>;$idx <span style="color: #FF0000;">-lt</span> <span style="color: #800080;">$bytes</span>.length;$idx<span style="color: pink;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
<span style="color: pink;">&gt;&gt;</span> <span style="color: #800080;">$pwr</span> <span style="color: pink;">=</span> <span style="color: #800080;">$bytes</span>.length<span style="color: pink;">-</span><span style="color: #800080;">$idx</span><span style="color: pink;">-</span><span style="color: #804000;">1</span>;<br />
<span style="color: pink;">&gt;&gt;</span> <span style="color: #800080;">$number</span><span style="color: pink;">+=</span> <span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$idx</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#91;</span>math<span style="color: #000000;">&#93;</span>::pow<span style="color: #000000;">&#40;</span>256<span style="color: pink;">,</span><span style="color: #800080;">$pwr</span><span style="color: #000000;">&#41;</span><br />
<span style="color: pink;">&gt;&gt;</span><span style="color: #000000;">&#125;</span><br />
<span style="color: pink;">&gt;&gt;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>Write<span style="color: pink;">-</span>Host <span style="color: #800000;">&quot;The Value via method 1 is [$number]&quot;</span><br />
The Value via method 1 is <span style="color: #000000;">&#91;</span>2712847316<span style="color: #000000;">&#93;</span><br />
<br />
The second version uses the Math::Pow method to <span style="color: #0000FF;">do</span> help <span style="color: #0000FF;">do</span> the exponentiation:<span style="color: #000000;">&#40;</span>byte1 <span style="color: pink;">*</span> <span style="color: #804000;">256</span>^<span style="color: #804000;">3</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #000000;">&#40;</span>byte2 <span style="color: pink;">*</span> <span style="color: #804000;">256</span>^<span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #000000;">&#40;</span>byte3 <span style="color: pink;">*</span> <span style="color: #804000;">256</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> byte4<br />
<span style="color: #000000;">&#91;</span>cc lang<span style="color: pink;">=</span><span style="color: #800000;">&quot;powershell&quot;</span> tab_size<span style="color: pink;">=</span><span style="color: #800000;">&quot;3&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$key</span><span style="color: pink;">=</span><span style="color: #008080; font-weight: bold;">Get-Item</span> <span style="color: #800000;">&quot;HKLM:\Software\CRTCorp\Product_A&quot;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$bytes</span><span style="color: pink;">=</span> <span style="color: #800080;">$key</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;REG_DWORD_BIG_ENDIAN&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$number</span><span style="color: pink;">=</span>0<br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$number</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>0<span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::pow<span style="color: #000000;">&#40;</span>256<span style="color: pink;">,</span>3<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>1<span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Pow<span style="color: #000000;">&#40;</span>256<span style="color: pink;">,</span>2<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>2<span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> 256<span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>3<span style="color: #000000;">&#93;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>Write<span style="color: pink;">-</span>Host <span style="color: #800000;">&quot;The Value via Method 2 is [$number]&quot;</span><br />
The Value via method <span style="color: #804000;">3</span> is <span style="color: #000000;">&#91;</span><span style="color: #804000;">2712847316</span><span style="color: #000000;">&#93;</span></div></div>
<p>The third method was to write out the formula a little more explicitly so that (byte1 * 256^3) + (byte2 * 256^2) + (byte3 * 256^1) + (byte4 *256^0) becomes (byte1 * 16777216) + (byte2 * 65536) + (byte3 * 256) + byte4</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$key</span><span style="color: pink;">=</span><span style="color: #008080; font-weight: bold;">Get-Item</span> <span style="color: #800000;">&quot;HKLM:\Software\CRTCorp\Product_A&quot;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$bytes</span><span style="color: pink;">=</span> <span style="color: #800080;">$key</span>.GetValue<span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;REG_DWORD_BIG_ENDIAN&quot;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$number</span><span style="color: pink;">=</span>0<br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span><span style="color: #800080;">$number</span><span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>0<span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> 16777216<span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>1<span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> 65536<span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>2<span style="color: #000000;">&#93;</span> <span style="color: pink;">*</span> 256<span style="color: #000000;">&#41;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$bytes</span><span style="color: #000000;">&#91;</span>3<span style="color: #000000;">&#93;</span><br />
<span style="color: #008080; font-weight: bold;">PS</span> C:\<span style="color: pink;">&gt;</span>Write<span style="color: pink;">-</span>Host <span style="color: #800000;">&quot;The Value via method 3 is [$number]&quot;</span><br />
The Value via method <span style="color: #804000;">3</span> is <span style="color: #000000;">&#91;</span><span style="color: #804000;">2712847316</span><span style="color: #000000;">&#93;</span></div></div>
<p>I was curious though as to why it was we could get the individual bytes converted but there wasn&#8217;t (to me) an obvious way to do the whole value. I came across a mention of the Convert Class on MSDN which does make it possible. Convert class in the .Net framework. After playing around some I was able to come up with a different way using the Convert Class that to me seems a little cleaner. The Convert class has several overloaded methods. One version of the ToInt64 method converts a string version of a number into 64-bit signed integer. Either this or ToUInt32 will work for our purposes here. ToInt32 won&#8217;t work because of the value may incorrectly (for our purposed) return a negative (i.e. signed) integer. The call to the ToInt64 method  requires an argument that specifies the base of the number the string represents (in this case hex= base 16).  So in theory that would work if we were able to represent the bytes as a hex string.. i.e. 0xA1B2C3D4.  That&#8217;s when I came across a VBScript to Powershell page describing converting numbers from decimal to hex that helped fill in the missing piece. Putting these two things together I was able to come up with a function to use in my script which seemed to work.</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">#############################################################################</span><br />
<span style="color: #008000;">#Convert a Reg_DWORD_BIG_ENDIAN value to a number that makes sense to a human</span><br />
<span style="color: #008000;"># $convertee should be a byte array</span><br />
<span style="color: #008000;">#--------------------------------------------</span><br />
<span style="color: #0000FF;">function</span> Convert<span style="color: pink;">-</span>RBEToDecimal<span style="color: #000000;">&#40;</span><span style="color: #800080;">$convertee</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
<span style="color: #800080;">$tmpString</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;0x&quot;</span><br />
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$byte</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$convertee</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
<span style="color: #800080;">$tmpString</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;{0:X}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$byte</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0000FF;">Return</span> <span style="color: #000000;">&#91;</span>Convert<span style="color: #000000;">&#93;</span>::ToInt64<span style="color: #000000;">&#40;</span><span style="color: #800080;">$tmpString</span><span style="color: pink;">,</span><span style="color: #804000;">16</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #008000;">#############################################################################</span></div></div>
<p>The operative word here was &#8220;seemed&#8221;. I noticed in testing that there were instances where I got a very wrong answer.  As an example if the Registry value were (0xA102C4D4, or 2701312980 decimal) the function would return.  169001940 decimal as the value&#8230;I realized that in building $tmpString if the value of a particular byte was less than 16 it&#8217;d spit out a single character   0xC rather than 0&#215;0C. This was fine if I was interested in the value of a single byte but when concatenating the values together makes for a big difference in the resulting value as 0xA102C3D4 would become 0xA12C3D4. The resolution for this was to change the format string to pad the value with a leading 0 if necessary. So $tmpString += &#8220;{0:X}&#8221; -f $byte  became $tmpString += &#8220;{0:X2}&#8221; -f $byte.<br />
So the final function I ended up using looks like this:</p>
<div class="codecolorer-container powershell blackboard" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="powershell codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">############################################################################</span><br />
<span style="color: #008000;">#Convert a Reg_DWORD_BIG_ENDIAN value to a number that makes sense to a human</span><br />
<span style="color: #008000;"># $convertee should be a byte array</span><br />
<span style="color: #008000;">#--------------------------------------------</span><br />
<span style="color: #0000FF;">function</span> Convert<span style="color: pink;">-</span>RBEToDecimal<span style="color: #000000;">&#40;</span><span style="color: #800080;">$convertee</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
<span style="color: #800080;">$tmpString</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;0x&quot;</span><br />
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$byte</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$convertee</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><br />
<span style="color: #800080;">$tmpString</span> <span style="color: pink;">+=</span> <span style="color: #800000;">&quot;{0:X2}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$byte</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0000FF;">Return</span> <span style="color: #000000;">&#91;</span>Convert<span style="color: #000000;">&#93;</span>::ToInt64<span style="color: #000000;">&#40;</span><span style="color: #800080;">$tmpString</span><span style="color: pink;">,</span><span style="color: #804000;">16</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #008000;">###############################################################################</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://cars.lostroncos.org/2009/03/09/big_endian-registry-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
