<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>get-admin</title>
	
	<link>http://get-admin.com/blog</link>
	<description>Lessons of a Datacenter Administrator</description>
	<lastBuildDate>Tue, 31 Aug 2010 17:19:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Get-admin" /><feedburner:info uri="get-admin" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>VMworld Labs: Hands-On</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/tHHLs5g8k18/</link>
		<comments>http://get-admin.com/blog/?p=1188#comments</comments>
		<pubDate>Mon, 30 Aug 2010 18:36:16 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1188</guid>
		<description><![CDATA[First off, Happy VMworld everyone! It&#8217;s finally here, so let the socialization, learning and exhaustion begin. I had a bit of free time this morning so I decided to do a lab. I didn&#8217;t arrive early enough to get in on the preview like some others, however even after seeing their posts about it the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1188"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1188&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>First off, Happy VMworld everyone!  It&#8217;s finally here, so let the socialization, learning and exhaustion begin.</p>
<p>I had a bit of free time this morning so I decided to do a lab.  I didn&#8217;t arrive early enough to get in on the preview like some others, however even after seeing their posts about it the labs floor is quite impressive.  From the seats arranged so that everyone can see the projectors, to the apparent &#8220;control center&#8221; in the middle, it&#8217;s an impressive setup.</p>
<p>I chose lab 20&#8230;logging in was painless and provisioning of the virtual machines was extremely quick.  Access was also very good, initially anyway&#8230;more on that in a bit.  Progress through the lab was quick, directions were good, screen shots were accurate and quickly identified the key fields that needed to have data entry done.</p>
<p>Overall, I really enjoyed the lab.  In the last couple of years I haven&#8217;t done very many of them simply because most of the inability to get in.  This year I had zero wait, and there were a few free seats around me.  The dual monitor thin clients work well and PCoIP is amazing&#8230;</p>
<p>On that not so subtle transition, apparently the section I was in was running off the DC cloud.  For the first 75% of the lab, I couldn&#8217;t tell&#8230;in fact, if the WAN (I assume it was the WAN) hadn&#8217;t of had some issues, I would have never known.  Even when things started to go south and I could tell that latency was through the roof, the session was still usable, slow, but usable.  At one point the client lost connectivity, however it quickly regained and started the session exactly where I left off.</p>
<p>I&#8217;m incredibly impressed with the labs&#8230;it&#8217;s my first real work done on a thin client, over PCoIP using a &#8220;cloud&#8221; infrastructure.  If the provisioning of virtual machines works in the private cloud like it did for me today on VMware&#8217;s lab cloud, then we have a lot to look forward to in the future!</p>
<p>Outstanding work as always Labs Team, thank you!</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/tHHLs5g8k18" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1188</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1188&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=vmworld-labs-hands-on</feedburner:origLink></item>
		<item>
		<title>PowerShell: DataOnTAP and SID Convertions</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/Tgo0Znsx7fI/</link>
		<comments>http://get-admin.com/blog/?p=1124#comments</comments>
		<pubDate>Mon, 02 Aug 2010 12:26:36 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[OnTap SDK]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1124</guid>
		<description><![CDATA[This morning while standing up a new vScan A/V server I wanted to look up our McAfee service account.  I knew the account would be a domain account, and I knew it would be a member of the backup operators group on the filer.  With that in mind I ran the following. [0:4]&#62; Get-NaDomainUser -Group [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1124"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1124&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>This morning while standing up a new vScan A/V server I wanted to look up our McAfee service account.  I knew the account would be a domain account, and I knew it would be a member of the backup operators group on the filer.  With that in mind I ran the following.</p>
<table border="0" cellspacing="0" cellpadding="2" width="799" bgcolor="#00008b">
<tbody>
<tr>
<td width="797" valign="top">
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:4]&gt;</strong></span> Get-NaDomainUser -Group "Backup Operators"

SID
---
S-1-5-21-XXXXXXXX-XXXXXXXXX-XXXXXXXXX-112477
S-1-5-21-XXXXXXXX-XXXXXXXXX-XXXXXXXXX-111419
S-1-5-21-XXXXXXXX-XXXXXXXXX-XXXXXXXXX-146727
</span></span></span></pre>
</td>
</tr>
</tbody>
</table>
<p>Well that&#8217;s rather useless&#8230; Unfortunately, the OnTAP API doesn&#8217;t provide a means to convert a SID to a NTAccount.  This is normally accomplished via the &#8220;cifs lookup&#8221; command on the Ontap CLI, but that doesn&#8217;t help us much from the toolkit.  Fortunately .Net provides a native means to perform this conversion.  This isn&#8217;t new to anyone who has been following PowerShell for a while (/\/\o\/\/ first posted these function way back in the Monad days), but that doesn&#8217;t make them any less useful!</p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">ConvertTo-NTAccount</span>
<span style="color: #000000;">{</span>
    <span style="color: #00008b;">Param</span><span style="color: #000000;">(</span>
        <span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">Parameter</span><span style="color: #000000;">(</span><span style="color: #000000;">Mandatory</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>
            <span style="color: #000000;">HelpMessage</span><span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Enter the Sid to translate"</span><span style="color: #a9a9a9;">,</span>
            <span style="color: #000000;">ValueFromPipeLine</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>
            <span style="color: #000000;">ValueFromPipelineByPropertyName</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span>
        <span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
        <span style="color: #008080;">[string]</span>
        <span style="color: #ff4500;">$SID</span>
    <span style="color: #000000;">)</span>
    <span style="color: #00008b;">Process</span> <span style="color: #000000;">{</span>
        <span style="color: #ff4500;">$SIDObject</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #8a2be2;">system.security.principal.securityidentifier</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$SID</span><span style="color: #000000;">)</span>
        <span style="color: #0000ff;">write-output</span> <span style="color: #ff4500;">$SIDObject</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">translate</span><span style="color: #000000;">(</span><span style="color: #008080;">[system.security.principal.ntaccount]</span><span style="color: #000000;">)</span>
    <span style="color: #000000;">}</span>
<span style="color: #000000;">}</span>
<span style="color: #00008b;">Function</span> <span style="color: #8a2be2;">ConvertTo-SID</span>
<span style="color: #000000;">{</span>
    <span style="color: #00008b;">Param</span><span style="color: #000000;">(</span>
        <span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">Parameter</span><span style="color: #000000;">(</span><span style="color: #000000;">Mandatory</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>
            <span style="color: #000000;">HelpMessage</span><span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"Enter the NTAccount to translate in the form of domain\account"</span><span style="color: #a9a9a9;">,</span>
            <span style="color: #000000;">ValueFromPipeLine</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span>
            <span style="color: #000000;">ValueFromPipelineByPropertyName</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span>
        <span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
        <span style="color: #008080;">[string]</span>
        <span style="color: #ff4500;">$NTAccount</span>
    <span style="color: #000000;">)</span>
    <span style="color: #00008b;">Process</span> <span style="color: #000000;">{</span>
        <span style="color: #ff4500;">$NTAccountObject</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #8a2be2;">system.security.principal.NtAccount</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$NTaccount</span><span style="color: #000000;">)</span>
        <span style="color: #0000ff;">write-output</span> <span style="color: #ff4500;">$NTAccountObject</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">translate</span><span style="color: #000000;">(</span><span style="color: #008080;">[system.security.principal.securityidentifier]</span><span style="color: #000000;">)</span>
    <span style="color: #000000;">}</span>
<span style="color: #000000;">}

</span>Armed with my trusty functions Let's try this again!</pre>
<table border="0" cellspacing="0" cellpadding="2" width="799" bgcolor="#00008b">
<tbody>
<tr>
<td width="797" valign="top">
<pre><span style="color: #ffffff;"><span style="font-size: x-small;"><span style="font-family: Lucida Console; font-size: x-small;"><span style="color: #ffff00;"><strong>[0:15]&gt;</strong></span> Get-NaDomainUser -Group "Backup Operators" | ConvertTo-NTAccount

Value
-----
GetAdmin\svcAV
GetAdmin\svcBackup
GetAdmin\svcMNV
</span></span></span></pre>
</td>
</tr>
</tbody>
</table>
<p>Now that&#8217;s more like it!  This is what I Love about powershell.  In the past I would have had to push back on my sales rep, who would have inturn pushed back on the development team.  fast forward a year, and maybe I would have a workaround.  Or I would have had to try and glue a couple third party exe together (yuck). With PowerShell if I don&#8217;t like something I simply extend it in script.  No development, nothing complicated, just a couple line of PowerShell.  Best of all I can then provide this to the vendor as a concreate example of what I want in the next release (hint hint NetApp cifs lookup needs to be in the SDK!)</p>
<p>It really is just great stuff.<br />
~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/Tgo0Znsx7fI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1124</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1124&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-dataontap-and-sid-convertions</feedburner:origLink></item>
		<item>
		<title>Cacti: Monitor protocol statistics for NetApp volumes</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/1eP4FEv3TtE/</link>
		<comments>http://get-admin.com/blog/?p=1146#comments</comments>
		<pubDate>Wed, 21 Jul 2010 10:00:10 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Cacti]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1146</guid>
		<description><![CDATA[I have made no secret that I use two applications daily to monitor my infrastructure: Nagios and Cacti. I have created a fair number of scripts (and hopefully publishing more soon) to help Nagios monitor the different parts of the infrastructure, however I haven&#8217;t published many of my Cacti scripts previously. One of the most [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1146"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1146&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>I have made no secret that I use two applications daily to monitor my infrastructure: <a href="http://www.nagios.org/">Nagios</a> and <a href="http://www.cacti.net/">Cacti</a>.  I have created a fair number of <a href="http://get-admin.com/blog/?tag=nagios">scripts</a> (and hopefully publishing more soon) to help Nagios monitor the different parts of the infrastructure, however I haven&#8217;t published many of my <a href="http://get-admin.com/blog/?tag=cacti">Cacti scripts</a> previously.</p>
<p>One of the most useful is the config that I use to monitor the different protocol stats for volumes.  I created an indexed query so that the single script, and accompanying XML file, are capable of monitoring all the volumes, and I can select which graphs to create for each volume.  The polling script is loosely based off of the <a href="http://get-admin.com/blog/?p=763">multi-protocol realtime volume statistics</a> script that I created some time ago.</p>
<p><a href='http://get-admin.com/blog/wp-content/uploads/2010/07/Cacti_Volume_Stats.zip'>Download the template and script(s) here.</a></p>
<p>Some examples&#8230;</p>
<div style="clear: both;">
<strong>Total Operations, Latency</strong><br />
<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/total_ops.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/total_ops-300x116.jpg" alt="Cacti Volume Total Operations" title="Cacti Volume Total Operations" width="300" height="116" class="alignnone size-medium wp-image-1154" style="float: left; border: none; margin: 5px;" /></a>&nbsp;&nbsp;<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/total_lat.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/total_lat-300x112.jpg" alt="Cacti Volume Total Latency" title="Cacti Volume Total Latency" width="300" height="112" class="alignnone size-medium wp-image-1153" style="float: left; border: none; margin: 5px;" /></a>
</div>
<div style="clear: both;">
<strong>CIFS Operations, Latency</strong><br />
<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/cifs_ops.jpg" ><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/cifs_ops-300x116.jpg" alt="Cacti Volume CIFS Operations" title="Cacti Volume CIFS Operations" width="300" height="116" class="alignnone size-medium wp-image-1160" style="float: left; border: none; margin: 5px;" /></a>&nbsp;&nbsp;<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/cifs_lat.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/cifs_lat-300x126.jpg" alt="Cacti Volume CIFS Latency" title="Cacti Volume CIFS Latency" width="300" height="126" class="alignnone size-medium wp-image-1159" style="float: left; border: none; margin: 5px;" /></a>
</div>
<div style="clear: both;">
<strong>NFS Operations, Latency</strong><br />
<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/nfs_ops.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/nfs_ops-300x116.jpg" alt="Cacti Volume NFS Operations" title="Cacti Volume NFS Operations" width="300" height="116" class="alignnone size-medium wp-image-1156" style="float: left; border: none; margin: 5px;" /></a>&nbsp;&nbsp;<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/nfs_lat.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/nfs_lat-300x112.jpg" alt="Cacti Volume NFS Latency" title="Cacti Volume NFS Latency" width="300" height="112" class="alignnone size-medium wp-image-1155" style="float: left; border: none; margin: 5px;" /></a>
</div>
<div style="clear: both;">
<strong>iSCSI Operations, Latency</strong><br />
<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/iscsi_ops.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/iscsi_ops-300x116.jpg" alt="Cacti Volume iSCSI Operations" title="Cacti Volume iSCSI Operations" width="300" height="116" class="alignnone size-medium wp-image-1157" style="float: left; border: none; margin: 5px;" /></a>&nbsp;&nbsp;<a href="http://get-admin.com/blog/wp-content/uploads/2010/07/iscsi_lat.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/iscsi_lat-300x112.jpg" alt="Cacti Volume iSCSI Latency" title="Cacti Volume iSCSI Latency" width="300" height="112" class="alignnone size-medium wp-image-1158" style="float: left; border: none; margin: 5px;" /></a>
</div>
<div style="clear: both;"><span id="more-1146"></span></div>
<div style="clear: both;">
<p>Included in the templates are graphs for FCP and SAN operations, however I have none of those on my filer, so I have no graphs to show you.</p>
<p>These are especially useful for volumes that have multiple types of access happening.  For example, one of the systems that we have provides home directories to some users has both NFS and CIFS access enabled.  It is extremely helpful to see latency for each of the protocols as it can help diagnose certain errors&#8230;for example, our NIS domain had an error at one point that was causing authentication/authorization to be extremely slow, by monitoring the NFS latency, we helped narrow down the problem.</p>
<p>Because it is an indexed script query, you can select volumes to have each type of graph created for.  This makes it easy to select the volumes that you want to see, for instance, NFS latency using the standard list of objects that Cacti provides.</p>
<p>The setup is fairly simple&#8230;you&#8217;ll need the XML file that describes the inputs and outputs that Cacti communicates to the script, the perl script itself, and import the graph templates.  After placing the perl script in your <code>$cacti_path/scripts</code> directory, edit it and make sure that the NetApp SDK files are available.  I usually put them in perl&#8217;s main library path, but if you have them in the directory with your script(s) just make sure that a <code>use lib "/path/to/NetApp/sdk"</code> is in the script at the top.</p>
<p>After placing the <code>na-cacti-volume-stats.xml</code> file in <code>$path_cacti/resource/script_queries</code> directory, the only other modification you should need to make is to put the username and password that will be used to connect to the NetApp(s) in the XML file.  I don&#8217;t particularly like this, for one, it&#8217;s a security risk, and two, it&#8217;s very static.  You are welcome to modify the perl script so that it handles authentication a different way, but due to how Cacti behaves and the information that it passes (or doesn&#8217;t pass, as the case may be), the only way I have found to provide credentials is outside of the Cacti interface.</p>
<p>Anyway, that irritation aside, make sure that the permissions to the file are tightened such that only the Cacti user can access it, which helps to mitigate the security risk.  The second part of mitigation is to ensure that the user which connects and polls the NetApp has limited access.  You should not (SHOULD NOT!) be using root, or any other user in the Administrators group, to connect.  The user you use to connect doesn&#8217;t need to modify anything, so they shouldn&#8217;t have those role based accesses enabled.</p>
<p>That should get you started.  If you have any issues with the script or templates, please let me know in the comments.
</p></div>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/1eP4FEv3TtE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1146</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1146&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=cacti-monitor-protocol-statistics-for-netapp-volumes</feedburner:origLink></item>
		<item>
		<title>Nagios: Checking for abnormally large NetApp snapshots</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/qTjY0lDyp-w/</link>
		<comments>http://get-admin.com/blog/?p=1061#comments</comments>
		<pubDate>Mon, 19 Jul 2010 01:04:07 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Nagios]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1061</guid>
		<description><![CDATA[My philosophy with Nagios checks, especially with the NetApp, is that unless there are extenuating circumstances then I want all volumes (or whatever may be being checked) to be checked equally and at the same time. This means I don&#8217;t want to have to constantly add and remove checks from Nagios as volumes are added, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1061"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1061&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>My philosophy with Nagios checks, especially with the NetApp, is that unless there are extenuating circumstances then I want all volumes (or whatever may be being checked) to be checked equally and at the same time.  This means I don&#8217;t want to have to constantly add and remove checks from Nagios as volumes are added, deleted and modified.  I would much rather have one check that checks all of the volumes and reports on them en masse.  This means I don&#8217;t have to think about the check itself, but rather, only what it&#8217;s checking.</p>
<p>One of the many things that I regularly monitor on our multitude of NetApp systems is snapshots.  We have had issues, especially with LUNs, where the snapshots have gotten out of control.  </p>
<p>In order to prevent this, or at least hope that someone is watching the screen&#8230;, I wrote a quick script that checks to see if the total size of snapshots on a volume exceed the snap reserve.  Since not all of our volumes have a snap reserve, I also put in the ability to check the size of the snaps against the percentage of free space left in the volume.</p>
<p>This last measure is a little strange, but I think it works fairly well.  Take, for example, a 100GB volume.  If it is 50% full (50GB), there is no snap reserve and the alert percentage is left at the default of 40% free space, then the alert will happen when snapshots exceed about 15GB.  &#8220;But that&#8217;s not 40% of the free space&#8221;, I hear you saying.  Ahhh, but it is&#8230;you see as the snapshot(s) grow, there is less free space, which means that it takes a larger percentage as the free space shrinks.  So at 15GB of snapshots, there would be 35GB of free space, and 40% of 35GB is 14GB.</p>
<p>This causes the alerts to happen earlier than you may expect at first.  You can adjust this number to be a percentage of the total space in the volume if you like&#8230;however, why not just set a snap reserve at that point?  I chose to make the script this way in order to attempt to keep a little more free space in the volume, while not making a snap reserve mandatory.</p>
<p>One last word&#8230;please keep in mind this script does not check for a volume being filled, you should have other checks for that.  This merely checks to see if snapshots have exceeded a threshold of space in the volume to prevent them from taking up too much space.</p>
<p>Bring on the Perl&#8230;</p>
<p><span id="more-1061"></span></p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># check_na_snaps.pl - written by Andrew Sullivan, 2010-07-18</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Please report bugs and request improvements at http://get-admin.com/blog/?p=1061</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This is a Nagios script that checks a NetApp for volumes that have total snapshot</span>
<span style="color: #666666; font-style: italic;"># space consumed that exceeds the snap reserve, or exceeds the user specified </span>
<span style="color: #666666; font-style: italic;"># percentage of free space.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Options are:</span>
<span style="color: #666666; font-style: italic;">#   --hostname|-H =  (mandatory) hostname or IP of NetApp to connect to</span>
<span style="color: #666666; font-style: italic;">#   --username|-u =  (mandatory) username to connect with</span>
<span style="color: #666666; font-style: italic;">#   --password|-p =  (optional)  password for user, will be prompted if not supplied</span>
<span style="color: #666666; font-style: italic;">#   --protocol|-P =  (optional)  Currently only HTTP and HTTPS are available, HTTP</span>
<span style="color: #666666; font-style: italic;">#                                  is the default</span>
<span style="color: #666666; font-style: italic;">#   --freespace|-f = (optional)  Integer.  the amount of free space to use as a measure to </span>
<span style="color: #666666; font-style: italic;">#                                  determine if a snapshot is too large for vols that have </span>
<span style="color: #666666; font-style: italic;">#                                  no snap reserve set.  The default is 40%</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Examples:</span>
<span style="color: #666666; font-style: italic;">#   Basic check, no frills, 40% threshold</span>
<span style="color: #666666; font-style: italic;">#     check_na_snaps.pl --hostname toaster1 --username notRoot --password '$ecr3t'</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   Check using HTTPS, 20% threshold</span>
<span style="color: #666666; font-style: italic;">#     check_na_snaps.pl -H toaster1 -u notRoot -p '$ecr3t' -P 'HTTPS' -f 20</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># The OnTAP SDK is available here: http://communities.netapp.com/docs/DOC-1365</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Getopt<span style="color: #339933;">::</span><span style="color: #006600;">Long</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">:</span>config no_ignore_case<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> NaServer<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> NaElement<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># make sure you change this path to match your environment</span>
<span style="color: #000000; font-weight: bold;">use</span> lib <span style="color: #ff0000;">&quot;/usr/lib64/nagios/plugins&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> utils <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">%ERRORS</span> <span style="color: #0000ff;">&amp;print_revision</span> <span style="color: #0000ff;">&amp;support</span> <span style="color: #0000ff;">&amp;usage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$PROGNAME</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;check_na_snaps.pl&quot;</span><span style="color: #339933;">;</span>
&nbsp;
main<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> main <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$opts</span> <span style="color: #339933;">=</span> parse_options<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$server</span> <span style="color: #339933;">=</span> getFiler<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'hostname'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'username'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'password'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'protocol'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$volumes</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$request</span> <span style="color: #339933;">=</span> NaElement<span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'volume-list-info'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$result</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">invoke_elem</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">results_errno</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #ff0000;">'volume-list-info failed! Reason: '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">results_reason</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">exit</span> <span style="color: #0000ff;">$ERRORS</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'UNKNOWN'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># let's begin by looping through the volumes....</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$volume</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'volumes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">children_get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># we only want volumes that are online</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'state'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">eq</span> <span style="color: #ff0000;">&quot;online&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;"># we need some info, namely the amount of free space and the amount of space</span>
			<span style="color: #666666; font-style: italic;"># reserved for snapshots.  The latter is returned in 1024 byte blocks, so let's </span>
			<span style="color: #666666; font-style: italic;"># normalize on bytes...</span>
			<span style="color: #0000ff;">$volumes</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$name</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'free'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'size-available'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #0000ff;">$volumes</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$name</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapreserve'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'snapshot-blocks-reserved'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;"># now we need to get info on all the snapshots.  Unfortunately there is no way</span>
			<span style="color: #666666; font-style: italic;"># that I'm aware of to return simply the total size of all snaps, so we have </span>
			<span style="color: #666666; font-style: italic;"># to do it the long way</span>
			<span style="color: #0000ff;">$request</span> <span style="color: #339933;">=</span> NaElement<span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'snapshot-list-info'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #0000ff;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_add_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'terse'</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'false'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #0000ff;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_add_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'volume'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$snapshots</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">invoke_elem</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$snapshots</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">results_errno</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">print</span> <span style="color: #000000; font-weight: bold;">STDERR</span> <span style="color: #ff0000;">'snapmirror-get-status failed! Reason: '</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$snapshots</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">results_reason</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #000066;">exit</span> <span style="color: #0000ff;">$ERRORS</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'UNKNOWN'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$snapsize</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;"># ...the long way being loop through each one, look for the oldest and get it's</span>
			<span style="color: #666666; font-style: italic;"># cumulative total data.  This may take a while, so depending on the timeout</span>
			<span style="color: #666666; font-style: italic;"># for your checks, this may not always finish in time</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066;">scalar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$snapshots</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'snapshots'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">children_get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;"># make the &quot;first&quot; time impossible to achieve so that it always get's</span>
				<span style="color: #666666; font-style: italic;"># pushed out on the first iteration</span>
				<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$snaptime</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">999999999999</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$snap</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$snapshots</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'snapshots'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">children_get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$snap</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_int</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'access-time'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$snaptime</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #0000ff;">$snaptime</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$snap</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'access-time'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #0000ff;">$snapsize</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$snap</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">child_get_string</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'cumulative-total'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;"># snapsize is also returned in 1024 byte blocks, so let's normalize again</span>
				<span style="color: #0000ff;">$snapsize</span> <span style="color: #339933;">*=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #0000ff;">$volumes</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$name</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapsize'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$snapsize</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># now that we have the information for all volumes, check to see if we have any violators</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$vol_name</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066;">keys</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$volumes</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$volume</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$volumes</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$vol_name</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;"># is snap reserve turned on?</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapreserve'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;"># yes, check to see if the snapshots are greater than snapreserve</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapsize'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapreserve'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$errors</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;$vol_name reserve (&quot;</span> <span style="color: #339933;">.</span> printableSize<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapreserve'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> 
					<span style="color: #ff0000;">&quot;) &lt; consumed (&quot;</span> <span style="color: #339933;">.</span> printableSize<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'snapsize'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;); &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;"># no reserve, check the snap to free space ratio</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapsize'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'free'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">*</span> <span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'freespace'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$errors</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;$vol_name snapsize (&quot;</span> <span style="color: #339933;">.</span> printableSize<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'snapsize'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> 
					<span style="color: #ff0000;">&quot;) &gt; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'freespace'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;% free (&quot;</span> <span style="color: #339933;">.</span> 
					printableSize<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'free'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">*</span> <span style="color: #0000ff;">$opts</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'freespace'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;); &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># if any volumes have snaps out of line, alert the user and exit with a warning</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$errors</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;WARNING - &quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #0000ff;">$_</span> <span style="color: #b1b100;">for</span> <span style="color: #0000ff;">@$errors</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">exit</span> <span style="color: #0000ff;">$ERRORS</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'WARNING'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;OK - No volumes have overly large snapshots<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">exit</span> <span style="color: #0000ff;">$ERRORS</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'OK'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> getFiler <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hostname</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$username</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$password</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$protocol</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> NaServer<span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$hostname</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">set_style</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'LOGIN'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">set_admin_user</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$username</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">set_transport_type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$protocol</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$s</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> parse_options <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%options</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
		<span style="color: #ff0000;">'hostname'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'username'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'password'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'protocol'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'HTTP'</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'freespace'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'40'</span>
		<span style="color: #ff0000;">'help'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	GetOptions<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">\%options</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'hostname|H=s'</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'username|u=s'</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'password|p:s'</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'protocol|P:s'</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'freespace|f:i'</span><span style="color: #339933;">,</span>
		<span style="color: #ff0000;">'help|h'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$options</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'freespace'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'freespace'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'hostname'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">||</span> 
	    <span style="color: #339933;">!</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'username'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">||</span> 
	    <span style="color: #339933;">!</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'password'</span> <span style="color: #009900;">&#125;</span> <span style="color: #339933;">||</span> 
	    <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">'help'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Missing or invalid options!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		print_usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">exit</span> <span style="color: #0000ff;">$ERRORS</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'UNKNOWN'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">\%options</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> printableSize <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$size_string</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Bytes</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d bytes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Kilo bytes</span>
    <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%4.2fKB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Mega bytes</span>
    <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%4.2fMB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Giga bytes</span>
    <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%4.2fGB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Tera bytes</span>
    <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%4.2fTB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Peta bytes</span>
    <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%4.2fPB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$size_string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d bytes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066;">return</span> <span style="color: #0000ff;">$size_string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/Get-admin/~4/qTjY0lDyp-w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1061</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1061&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=nagios-checking-for-abnormally-large-netapp-snapshots</feedburner:origLink></item>
		<item>
		<title>VMware vSphere Hypervisor (ESXi) 4.1 kickstart – A.K.A. official “touchfree” ESXi installs</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/IHkY3yVcnr4/</link>
		<comments>http://get-admin.com/blog/?p=1131#comments</comments>
		<pubDate>Wed, 14 Jul 2010 10:00:07 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[ESXi]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[Kickstart]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1131</guid>
		<description><![CDATA[VMware is a facilitator. I know, you&#8217;re thinking &#8220;yeah, they facilitate my power/space/cooling savings, they facilitate infrastructure consolidation, IT agility, high availability, etc.&#8221;, but really, they facilitate me being lazy (which for sysadmins is a good thing&#8230;a lazy admin will only want to do a task once, then automate the sh*t out of it). I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1131"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1131&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>VMware is a facilitator.  I know, you&#8217;re thinking &#8220;yeah, they facilitate my power/space/cooling savings, they facilitate infrastructure consolidation, IT agility, high availability, etc.&#8221;, but really, they facilitate me being lazy (which for sysadmins is a good thing&#8230;a lazy admin will only want to do a task once, then automate the sh*t out of it).</p>
<p>I&#8217;ve already documented how <a href="http://get-admin.com/blog/?p=994">I hacked the ESXi 4.0 installer</a> to have it do the installation without interaction.  However, VMware has one-upped me and integrated kickstart into their installer.  This makes things VASTLY easier, requires no tomfoolery with the ISO, and is significantly more capable.</p>
<p>This blog post will be just a short one to demonstrate how easy it is now to have the install be &#8220;touch-free&#8221;.  I am working on some more complex examples in the coming days.</p>
<p>So without further blithering from me, on with the install! Put the CD in the drive (or mount the iso remotely), boot the server.  When it reaches the boot options menu: </p>
<p><a href="http://get-admin.com/blog/wp-content/uploads/2010/07/1.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/1-300x208.jpg" alt="ESXi 4.1 Boot options screen" title="ESXi 4.1 Boot Options" width="300" height="208" class="aligncenter size-medium wp-image-1132" /></a></p>
<p>Press tab to append options to the boot line.  Append the following after the <code>vmkboot.gz</code>, but before the <code>---</code> after it.</p>
<p><code>ks=file://etc/vmware/weasel/ks.cfg</code></p>
<p>It is VERY IMPORTANT that you place the kickstart file location after vmkboot.gz, but before the next boot module. It should not be at the end.  </p>
<p><code>mboot.c32 vmkboot.gz ks=file://etc/vmware/weasel/ks.cfg --- vmkernel.gz ---sys.vgz ---cim.vgz --- ienviron.vgz --- install.vgz</code></p>
<p>Here is an example:</p>
<p><a href="http://get-admin.com/blog/wp-content/uploads/2010/07/2.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/2-300x208.jpg" alt="ESXi 4.1 Boot Options with KS" title="ESXi 4.1 Boot Options with KS" width="300" height="208" class="aligncenter size-medium wp-image-1133" /></a></p>
<p>When you&#8217;re done, press enter.  It will begin to load the data off the CD, and when the different install modules are done it should simply begin to install ESXi just like how I had hacked it together previously&#8230;</p>
<p><a href="http://get-admin.com/blog/wp-content/uploads/2010/07/3.jpg"><img src="http://get-admin.com/blog/wp-content/uploads/2010/07/3-300x208.jpg" alt="ESXi 4.1 KS Install" title="ESXi 4.1 KS Install" width="300" height="208" class="aligncenter size-medium wp-image-1134" /></a></p>
<p>The only thing left will be to press &#8220;Enter&#8221; when it&#8217;s done (why?!).</p>
<p>A word of caution&#8230;the kickstart that VMware has provided will automatically select and format the first disk that it finds, regardless of it being local or &#8220;remote&#8221; (i.e. a SAN LUN).  I would assume that the vast majority of the time it&#8217;s going to find the local disks first, however&#8230;&#8230;..</p>
<p>Hopefully in the next few days I&#8217;ll have some more time to play with the new kickstart features and post some more examples.  VMware has really done some great things with this process and it is now possible to have the entire process be automated&#8230;<br />
	1) use DHCP to provide the &#8220;permanent&#8221; IP<br />
	2) use a network PXE boot for the media and to provide a KS file<br />
	3) use the <code>--post</code> section of the kickstart file to have the server reach out and touch a vCLI or PowerCLI configuration host and provide permanent configuration.</p>
<p>The reason that step one should provide the actual IP is that it provides an easy way of having your configuration host (vCLI or PowerCLI) know what IP (and potentially hostname) to assign to the host.</p>
<p>Good luck, and thanks to VMware for (finally) integrating kickstart with ESXi!</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/IHkY3yVcnr4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1131</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1131&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=vmware-vsphere-hypervisor-esxi-4-1-kickstart-a-k-a-official-touchfree-esxi-installs</feedburner:origLink></item>
		<item>
		<title>vSphere: Console… we don’t need no stink’in console</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/_ATW0-LQwic/</link>
		<comments>http://get-admin.com/blog/?p=1113#comments</comments>
		<pubDate>Tue, 13 Jul 2010 12:56:32 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[Virtulization]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1113</guid>
		<description><![CDATA[I won&#8217;t attempt to provide a feature rundown or tell you why vSphere 4.1 is the greatest thing since sliced bread.  It appears to be a solid release, but  I&#8217;ll leave that analysis to the experts&#8230;Instead I want to talk about the vSphere hypervisor (previously ESXi). Why the name change? Simple what was previously mis-branded [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1113"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1113&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>I won&#8217;t attempt to provide a feature rundown or tell you why vSphere 4.1 is the greatest thing since sliced bread.  It appears to be a solid release, but  I&#8217;ll leave that analysis to the experts&#8230;Instead I want to talk about the vSphere hypervisor (previously ESXi).</p>
<p>Why the name change? Simple what was previously mis-branded as a separate technology is really the hypervisors core.  Previously in ESX3.5, ESXi was a separate technology, but as of vSphere 4 they have had a unified core.   In-fact the product we like to think about as vSphere 4.0/4.1 is really just a vSphere hypervisor with a special management VM!  This is important, the only difference is the console which is nothing more than a VM!</p>
<p>So why the distinction, Why now?  VMware is playing it&#8217;s hand this round because that special VM is going bye, bye.  The Next release of vSphere will not have a service console.. PAINIC&#8230;. RUN IN CIRCLES THE ZOMBIES ARE COMMING!!!</p>
<p>Don&#8217;t Panic, Personally I applaud the move.  Over the past year and a half I&#8217;ve heard every argument against the console less hypervisor, but honestly I chalk it all up to people fear change.  There are a couple thousand admins who have invested a lot of time mastering vSphere, and VMware is about to change the whole game on them.  These guys/gals bring up several arguments against the console less hypervisor, I&#8217;ll attempt to offer my counter argument to these points.</p>
<p>Q. No 3rd Party agents.</p>
<p>A. It has been public knowledge that the console was going away, and as of vSphere 4.0 VMware shipped a new management appliance vMA.  One of the intended uses of this appliance was to install 3rd party agents.  So you see we do still have 3rd Party agents they just need to be rewritten.  In most cases this will result in a better product. Unfortunately, the vast majority of 3rd party software, could better be described as a really complex perl script running over ssh!</p>
<p>Q. Hardware monitors/plug-in</p>
<p>A. Part of the original ESXi 3.5 release was the introduction of a rudimentary CIM provider.  This provider has been fully expanded , and made extensible.  While it is a change from the traditional agent based monitors CIM does fill in this gap.</p>
<p>Q. Automating common tasks.</p>
<p>A. As of vSphere 4.1 Tech Support Mode supports SSH, but you should really be using either PowerCLI or the vCLI!  While it is true that are still a couple of things that can only be done via the console.  I&#8217;m confident VMware will fix those gaps before putting the console out to pasture.</p>
<p>Q. Security</p>
<p>A. So this is the big one, and my personal pet peeve.  I&#8217;ve heard security experts bash the vSphere hypervisor claiming it was insecure.  I just don&#8217;t understand this stance, admittedly I&#8217;m no security expert.  I only work with the federal government in some of the most secure data centers in the world, but what do I know&#8230;</p>
<p>Let&#8217;s break this down shall we&#8230; The only difference is a VM.   Admittedly this VM has special connections into the vmkernal, but it&#8217;s still just a VM.  How exactly does the inclusion of a VM make the hypervisor more secure?  In my opinion the exclusion of this VM instantly increased the security posture of most organizations.  The reason for this simple, it was hard to properly harden the console.  Alternatively it was all too easy to open a critical security hole, and expose ones infrastructure with the console.</p>
<p>Yes you still have to do several things to really lock down the console less hypervisor, but it&#8217;s not nearly the feat the console once was.  In fact it&#8217;s simple;</p>
<p style="padding-left: 30px;">1. Modify the Proxy.xml (turning off all unneeded web services, and make everything use https).<br />
2. Enable Lockdown mode.<br />
3. Physical security.</p>
<p>That&#8217;s it folks, that&#8217;s all it takes to secure the hypervisor.  There are a couple hundred other little things necessary to design a secure infrastructure, but as you can see the hypervisor is easy!  In fact I&#8217;m so confident in this I&#8217;m willing to hold a Bobby Flay style throw down.  If you have the means to provide a  pair of internet facing vSphere hosts. I&#8217;ll secure the console less hypervisor, we&#8217;ll get TexiWill to harden the legacy console based hypervisor, and then we&#8217;ll release the IP&#8217;s to the world.  Have at it, folks I bet the console less hypervisor holds up at least as long as the legacy hypervisor!</p>
<p>Why so brash? Well it will take an exploit to get in to the console less hypervisor, and any exploit will also be present in the legacy hypervisor.  The console less vSphere hypervisor without access to the physical host or vCenter there is simply no other way in.   Remember this isn&#8217;t Linux or BSD or UNIX&#8230; it&#8217;s vSphere it&#8217;s practicality firmware, and the whole point was to remove all that crap that weaken the security , and stability to begin with!</p>
<p>I really want to put this to bed!  Let&#8217;s develop the to do list for VMware.  The 10-20 things they need to fix before they can finally kill the console.  Then let&#8217;s collectively shut up about it.  It&#8217;s going to happen, and complaining with arbitrary little gripes&#8230; or demanding NDA meetings with engineers isn&#8217;t going to stop any of it.  The Task at hand is simple, weed out the crap, and focus on what needs to be fixed in vSphere v.Next.</p>
<p>If we missed something let us know in the comments.<br />
~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/_ATW0-LQwic" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1113</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1113&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=vsphere-console-we-dont-need-no-stinkin-console</feedburner:origLink></item>
		<item>
		<title>PowerShell: DataOnTap Realtime Multiprotocol Volume Latency</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/rRwzqwqlknM/</link>
		<comments>http://get-admin.com/blog/?p=1097#comments</comments>
		<pubDate>Wed, 07 Jul 2010 17:40:33 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1097</guid>
		<description><![CDATA[I had some free time yesterday morning as I couldn&#8217;t sleep after the long weekend. I used the time to dig into into the DataOnTap PowerShell Toolkit.  I started with an easy port of one of Andrews performance monitoring scripts.  I won&#8217;t go into as it&#8217;s very straight forward, but I will say so far [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1097"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1097&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>I had some free time yesterday morning as I couldn&#8217;t sleep after the long weekend.  I used the time to dig into into the <a href="http://communities.netapp.com/community/interfaces_and_tools/data_ontap_powershell_toolkit">DataOnTap PowerShell Toolkit</a>.  I started with an easy port of one of Andrews <a href="http://get-admin.com/blog/?p=763">performance monitoring scripts</a>.  I won&#8217;t go into as it&#8217;s very straight forward, but I will say so far I am very pleased with the DataOnTAP toolkit. </p>
<pre class='PowerShellColorizedScript'><span style='color:#006400'><#
.SYNOPSIS
    Get the different protocol latencies for a specified volume.
.DESCRIPTION
    Get the different protocol latencies for a specified volume.
.PARAMETER Volume
    Volume to retrieve the latency.
.PARAMETER Protocol
    Protocol to collect latency for valid values are 'all','nfs','cifs','san','fcp','iscsi'
.PARAMETER Interval
    The interval between iterations in seconds, default is 15 seconds
.PARAMETER Count
    the number of iterations to execute, default is infinant
.PARAMETER Controller
    NetApp Controller to query.
.EXAMPLE
    .Get-NaVolumeLatency.ps1 -Volume vol0 

    Get the average latency for all protocols on vol0
.EXAMPLE
    Get-NaVol | .Get-NaVolumeLatency.ps1 -Interval 5 -count 5 | ft

    Get the average latency for all protocols, all volumes, 5 samples, 5 seconds apart.
.EXAMPLE
    .Get-NaVolumeLatency.ps1 -Volume vol0 -protocol nfs

    Get the NFS latency for vol0
#></span>
<span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>cmdletBinding</span><span style='color:#000000'>(</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
<span style='color:#00008b'>Param</span><span style='color:#000000'>(</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>Parameter</span><span style='color:#000000'>(</span><span style='color:#000000'>Mandatory</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$true</span><span style='color:#a9a9a9'>,</span>
        <span style='color:#000000'>HelpMessage</span><span style='color:#a9a9a9'>=</span><span style='color:#8b0000'>"Volume name to retrieve latency counters from."</span><span style='color:#a9a9a9'>,</span>
        <span style='color:#000000'>ValueFromPipelineByPropertyName</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$true</span><span style='color:#a9a9a9'>,</span>
        <span style='color:#000000'>ValueFromPipeLine</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$true</span>
    <span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>Alias</span><span style='color:#000000'>(</span><span style='color:#8b0000'>"Name"</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#008080'>[string]</span>
    <span style='color:#ff4500'>$Volume</span>
<span style='color:#a9a9a9'>,</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>Parameter</span><span style='color:#000000'>(</span><span style='color:#000000'>Mandatory</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$false</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>ValidateSet</span><span style='color:#000000'>(</span><span style='color:#8b0000'>'all'</span><span style='color:#a9a9a9'>,</span><span style='color:#8b0000'>'nfs'</span><span style='color:#a9a9a9'>,</span><span style='color:#8b0000'>'cifs'</span><span style='color:#a9a9a9'>,</span><span style='color:#8b0000'>'san'</span><span style='color:#a9a9a9'>,</span><span style='color:#8b0000'>'fcp'</span><span style='color:#a9a9a9'>,</span><span style='color:#8b0000'>'iscsi'</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#008080'>[string]</span>
    <span style='color:#ff4500'>$Protocol</span><span style='color:#a9a9a9'>=</span><span style='color:#8b0000'>'all'</span>
<span style='color:#a9a9a9'>,</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>Parameter</span><span style='color:#000000'>(</span><span style='color:#000000'>Mandatory</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$false</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#008080'>[int]</span>
    <span style='color:#ff4500'>$Interval</span><span style='color:#a9a9a9'>=</span><span style='color:#800080'>15</span>
<span style='color:#a9a9a9'>,</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>Parameter</span><span style='color:#000000'>(</span><span style='color:#000000'>Mandatory</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$false</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#008080'>[string]</span>
    <span style='color:#ff4500'>$count</span>
<span style='color:#a9a9a9'>,</span>
    <span style='color:#a9a9a9'>[</span><span style='color:#add8e6'>Parameter</span><span style='color:#000000'>(</span><span style='color:#000000'>Mandatory</span><span style='color:#a9a9a9'>=</span><span style='color:#ff4500'>$false</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>]</span>
    <span style='color:#008080'>[NetApp.Ontapi.Filer.NaController]</span>
    <span style='color:#ff4500'>$Controller</span><span style='color:#a9a9a9'>=</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$CurrentNaController</span><span style='color:#000000'>)</span>
<span style='color:#000000'>)</span>
<span style='color:#00008b'>Begin</span>
<span style='color:#000000'>{</span>
    <span style='color:#00008b'>IF</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$Protocol</span> <span style='color:#a9a9a9'>-eq</span> <span style='color:#8b0000'>'all'</span><span style='color:#000000'>)</span>
    <span style='color:#000000'>{</span>
       <span style='color:#ff4500'>$Counters</span> <span style='color:#a9a9a9'>=</span> <span style='color:#000000'>@(</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>'read_latency'</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
       <span style='color:#a9a9a9'>,</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>'write_latency'</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
       <span style='color:#a9a9a9'>,</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>'other_latency'</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
       <span style='color:#a9a9a9'>,</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>'avg_latency'</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
        <span style='color:#000000'>)</span>
    <span style='color:#000000'>}</span>
    <span style='color:#00008b'>Else</span>
    <span style='color:#000000'>{</span>
        <span style='color:#ff4500'>$Counters</span> <span style='color:#a9a9a9'>=</span> <span style='color:#000000'>@(</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span>  <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>"$($Protocol.ToLower())_read_latency"</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
        <span style='color:#a9a9a9'>,</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>"$($Protocol.ToLower())_write_latency"</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
        <span style='color:#a9a9a9'>,</span>
            <span style='color:#000000'>@{</span>
                <span style='color:#000000'>Counter</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>"$($Protocol.ToLower())_other_latency"</span>
                <span style='color:#000000'>Base</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
                <span style='color:#000000'>unit</span>     <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>''</span>
            <span style='color:#000000'>}</span>
        <span style='color:#000000'>)</span>
    <span style='color:#000000'>}</span>
    <span style='color:#00008b'>foreach</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$c</span> <span style='color:#00008b'>in</span> <span style='color:#ff4500'>$Counters</span><span style='color:#000000'>)</span>
    <span style='color:#000000'>{</span>
        <span style='color:#0000ff'>Get-NaPerfCounter</span> <span style='color:#000080'>-Name</span> <span style='color:#8b0000'>'volume'</span> <span style='color:#000080'>-Controller</span> <span style='color:#ff4500'>$Controller</span> <span style='color:#a9a9a9'>|</span>
            <span style='color:#0000ff'>Where-Object</span> <span style='color:#000000'>{</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>name</span> <span style='color:#a9a9a9'>-eq</span> <span style='color:#ff4500'>$c</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Counter</span><span style='color:#000000'>}</span> <span style='color:#a9a9a9'>|</span>
            <span style='color:#0000ff'>ForEach-Object</span> <span style='color:#000000'>{</span>
                <span style='color:#ff4500'>$c</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span> <span style='color:#a9a9a9'>=</span> <span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>BaseCounter</span>
                <span style='color:#ff4500'>$c</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>unit</span> <span style='color:#a9a9a9'>=</span> <span style='color:#00008b'>switch</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>unit</span><span style='color:#000000'>)</span> <span style='color:#000000'>{</span>
                    <span style='color:#8b0000'>"microsec"</span>  <span style='color:#000000'>{</span><span style='color:#800080'>10000</span><span style='color:#000000'>}</span>
                    <span style='color:#8b0000'>"millisec"</span>  <span style='color:#000000'>{</span><span style='color:#800080'>1</span><span style='color:#000000'>}</span>
                <span style='color:#000000'>}</span>
            <span style='color:#000000'>}</span>
    <span style='color:#000000'>}</span>
<span style='color:#000000'>}</span>
<span style='color:#00008b'>Process</span>
<span style='color:#000000'>{</span>            

    <span style='color:#006400'># Check if volume exists.</span>
    <span style='color:#00008b'>if</span> <span style='color:#000000'>(</span><span style='color:#a9a9a9'>-Not</span> <span style='color:#000000'>(</span><span style='color:#000000'>(</span><span style='color:#0000ff'>get-navol</span> <span style='color:#000080'>-Controller</span> <span style='color:#ff4500'>$Controller</span><span style='color:#a9a9a9'>|</span><span style='color:#0000ff'>select</span> <span style='color:#000080'>-ExpandProperty</span> <span style='color:#8a2be2'>Name</span><span style='color:#000000'>)</span> <span style='color:#a9a9a9'>-contains</span> <span style='color:#ff4500'>$Volume</span><span style='color:#000000'>)</span><span style='color:#000000'>)</span> <span style='color:#000000'>{</span>
        <span style='color:#0000ff'>Write-Warning</span> <span style='color:#8b0000'>"$volume doesn't exist!"</span>
        <span style='color:#00008b'>break</span><span style='color:#000000'>;</span>
    <span style='color:#000000'>}</span>
    <span style='color:#ff4500'>$iteration</span> <span style='color:#a9a9a9'>=</span> <span style='color:#800080'>0</span>
    <span style='color:#ff4500'>$first</span> <span style='color:#a9a9a9'>=</span> <span style='color:#ff4500'>$null</span>
    <span style='color:#006400'>#loop untill we're done or Cntr ^c </span>
    <span style='color:#00008b'>while</span> <span style='color:#000000'>(</span><span style='color:#000000'>(</span><span style='color:#a9a9a9'>!</span><span style='color:#ff4500'>$Count</span><span style='color:#000000'>)</span> <span style='color:#a9a9a9'>-or</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$iteration</span> <span style='color:#a9a9a9'>-le</span> <span style='color:#ff4500'>$count</span><span style='color:#000000'>)</span><span style='color:#000000'>)</span>
    <span style='color:#000000'>{</span>
        <span style='color:#ff4500'>$second</span> <span style='color:#a9a9a9'>=</span> <span style='color:#0000ff'>New-Object</span> <span style='color:#8a2be2'>Collections.HashTable</span>
        <span style='color:#0000ff'>Get-NaPerfData</span> <span style='color:#000080'>-Name</span> <span style='color:#8a2be2'>volume</span> <span style='color:#000000'>`
</span>            <span style='color:#000080'>-Instances</span> <span style='color:#ff4500'>$Volume</span> <span style='color:#000000'>`
</span>            <span style='color:#000080'>-Controller</span> <span style='color:#ff4500'>$Controller</span> <span style='color:#000000'>`
</span>            <span style='color:#000080'>-Counters</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$Counters</span><span style='color:#a9a9a9'>|</span><span style='color:#0000ff'>%</span><span style='color:#000000'>{</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>base</span><span style='color:#a9a9a9'>,</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>counter</span><span style='color:#000000'>}</span><span style='color:#000000'>)</span> <span style='color:#a9a9a9'>|</span>
            <span style='color:#0000ff'>Select-Object</span> <span style='color:#000080'>-ExpandProperty</span> <span style='color:#8a2be2'>Counters</span> <span style='color:#a9a9a9'>|</span>
            <span style='color:#0000ff'>ForEach-Object</span> <span style='color:#000000'>{</span>
                <span style='color:#ff4500'>$second</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>add</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Name</span><span style='color:#a9a9a9'>,</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>value</span><span style='color:#000000'>)</span>
            <span style='color:#000000'>}</span>            

        <span style='color:#00008b'>if</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$first</span> <span style='color:#a9a9a9'>-and</span> <span style='color:#ff4500'>$second</span><span style='color:#000000'>)</span>
        <span style='color:#000000'>{</span>
            <span style='color:#ff4500'>$results</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>""</span> <span style='color:#a9a9a9'>|</span> <span style='color:#0000ff'>Select-Object</span> <span style='color:#000080'>-Property</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$Counters</span><span style='color:#a9a9a9'>|</span><span style='color:#0000ff'>%</span><span style='color:#000000'>{</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>base</span><span style='color:#a9a9a9'>,</span><span style='color:#ff4500'>$_</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>counter</span><span style='color:#000000'>}</span><span style='color:#000000'>)</span>
            <span style='color:#00008b'>foreach</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$v</span> <span style='color:#00008b'>in</span> <span style='color:#ff4500'>$Counters</span><span style='color:#000000'>)</span>
            <span style='color:#000000'>{</span>
                <span style='color:#00008b'>IF</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$second</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span><span style='color:#a9a9a9'>]</span> <span style='color:#a9a9a9'>-gt</span> <span style='color:#ff4500'>$first</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span><span style='color:#a9a9a9'>]</span><span style='color:#000000'>)</span>
                <span style='color:#000000'>{</span>
                    <span style='color:#006400'>#calculate the average over our interval</span>
                    <span style='color:#ff4500'>$avg</span> <span style='color:#a9a9a9'>=</span> <span style='color:#000000'>(</span><span style='color:#ff4500'>$second</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Counter</span><span style='color:#a9a9a9'>]</span> <span style='color:#a9a9a9'>-</span> <span style='color:#ff4500'>$first</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Counter</span><span style='color:#a9a9a9'>]</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>/</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$second</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span><span style='color:#a9a9a9'>]</span> <span style='color:#a9a9a9'>-</span> <span style='color:#ff4500'>$first</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span><span style='color:#a9a9a9'>]</span><span style='color:#000000'>)</span>
                    <span style='color:#006400'>#conver to ms</span>
                    <span style='color:#ff4500'>$results</span><span style='color:#a9a9a9'>.</span><span style='color:#8b0000'>"$($v.Base)"</span> <span style='color:#a9a9a9'>=</span> <span style='color:#008080'>[math]</span><span style='color:#a9a9a9'>::</span><span style='color:#000000'>Round</span><span style='color:#000000'>(</span><span style='color:#000000'>(</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$second</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span><span style='color:#a9a9a9'>]</span> <span style='color:#a9a9a9'>-</span> <span style='color:#ff4500'>$first</span><span style='color:#a9a9a9'>[</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>Base</span><span style='color:#a9a9a9'>]</span><span style='color:#000000'>)</span><span style='color:#a9a9a9'>/</span><span style='color:#ff4500'>$Interval</span><span style='color:#000000'>)</span><span style='color:#000000'>)</span>
                    <span style='color:#ff4500'>$results</span><span style='color:#a9a9a9'>.</span><span style='color:#8b0000'>"$($v.Counter)"</span> <span style='color:#a9a9a9'>=</span> <span style='color:#000000'>(</span><span style='color:#8b0000'>"{0} ms"</span> <span style='color:#a9a9a9'>-f</span> <span style='color:#008080'>[math]</span><span style='color:#a9a9a9'>::</span><span style='color:#000000'>Round</span><span style='color:#000000'>(</span><span style='color:#ff4500'>$avg</span><span style='color:#a9a9a9'>/</span><span style='color:#ff4500'>$v</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>unit</span><span style='color:#000000'>)</span><span style='color:#000000'>)</span>
                <span style='color:#000000'>}</span>
                <span style='color:#00008b'>Else</span>
                <span style='color:#000000'>{</span>
                    <span style='color:#ff4500'>$results</span><span style='color:#a9a9a9'>.</span><span style='color:#8b0000'>"$($v.Base)"</span> <span style='color:#a9a9a9'>=</span> <span style='color:#800080'>0</span>
                    <span style='color:#ff4500'>$results</span><span style='color:#a9a9a9'>.</span><span style='color:#8b0000'>"$($v.Counter)"</span> <span style='color:#a9a9a9'>=</span> <span style='color:#8b0000'>"0 ms"</span>
                <span style='color:#000000'>}</span>
            <span style='color:#000000'>}</span>
            <span style='color:#0000ff'>Write-Output</span> <span style='color:#ff4500'>$results</span><span style='color:#a9a9a9'>|</span> <span style='color:#0000ff'>Add-Member</span> <span style='color:#8a2be2'>NoteProperty</span> <span style='color:#8b0000'>'Volume'</span> <span style='color:#ff4500'>$Volume</span> <span style='color:#000080'>-PassThru</span>
        <span style='color:#000000'>}</span>
        <span style='color:#0000ff'>Start-Sleep</span> <span style='color:#000080'>-Seconds</span> <span style='color:#ff4500'>$Interval</span>
        <span style='color:#ff4500'>$first</span> <span style='color:#a9a9a9'>=</span> <span style='color:#ff4500'>$second</span><span style='color:#a9a9a9'>.</span><span style='color:#000000'>clone</span><span style='color:#000000'>(</span><span style='color:#000000'>)</span>
        <span style='color:#ff4500'>$iteration</span><span style='color:#a9a9a9'>++</span>
    <span style='color:#000000'>}</span>
<span style='color:#000000'>}</span>
</pre>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/rRwzqwqlknM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1097</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1097&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-dataontap-realtime-multiprotocol-volume-latency</feedburner:origLink></item>
		<item>
		<title>PowerCLI: Reconnect VMhosts after changing vCenter certificates</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/a_xOcp8Anrw/</link>
		<comments>http://get-admin.com/blog/?p=1082#comments</comments>
		<pubDate>Tue, 29 Jun 2010 14:06:16 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[HOW TO]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vCenter]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1082</guid>
		<description><![CDATA[If you have ever changed the vCenter server certificates, you&#8217;ve experienced having all your hosts disconnected from vCenter.  I couldn&#8217;t imagine reconnecting them one at a time&#8230; You could do this all natively in PowerCLI, but that would require you to fully remove and then add the hosts.  That is very inconvenient, and almost as [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1082"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1082&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you have ever changed the vCenter server certificates, you&#8217;ve experienced having all your hosts disconnected from vCenter.  I couldn&#8217;t imagine reconnecting them one at a time&#8230; You could do this all natively in PowerCLI, but that would require you to fully remove and then add the hosts.  That is very inconvenient, and almost as much trouble as doing it by hand&#8230; In this case it is both faster and easier to just use the native vSphere API.</p>
<pre class="PowerShellColorizedScript"><span style="color: #006400;"># Get the hostsystem object for every host currently disconnected.</span>
<span style="color: #ff4500;">$VMhosts</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-View</span> <span style="color: #000080;">-ViewType</span> <span style="color: #8b0000;">'Hostsystem'</span> <span style="color: #000000;">`
</span>                    <span style="color: #000080;">-Property</span> <span style="color: #8b0000;">'name'</span> <span style="color: #000000;">`
</span>                    <span style="color: #000080;">-Filter</span> <span style="color: #000000;">@{</span><span style="color: #8b0000;">"Runtime.ConnectionState"</span><span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">"disconnected"</span><span style="color: #000000;">}</span>            

<span style="color: #00008b;">Foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$VMhost</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$VMhosts</span><span style="color: #000000;">)</span>
<span style="color: #000000;">{</span>
    <span style="color: #006400;"># Create a reconnect spec</span>
    <span style="color: #ff4500;">$HostConnectSpec</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #8a2be2;">VMware.Vim.HostConnectSpec</span>
    <span style="color: #ff4500;">$HostConnectSpec</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">hostName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$VMhost</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">name</span>
    <span style="color: #ff4500;">$HostConnectSpec</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">userName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">'root'</span>
    <span style="color: #ff4500;">$HostConnectSpec</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">password</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">'PassWord'</span>            

    <span style="color: #006400;"># Reconnect the host</span>
    <span style="color: #ff4500;">$taskMoRef</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$VMhost</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ReconnectHost_Task</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$HostConnectSpec</span><span style="color: #000000;">)</span>            

    <span style="color: #006400;"># optional, but i like to return a task object, that way I can </span>
    <span style="color: #006400;"># easily integrate this into a pipeline later if need be.</span>
    <span style="color: #0000ff;">Get-VIObjectByVIView</span> <span style="color: #000080;">-MORef</span> <span style="color: #ff4500;">$taskMoRef</span>
<span style="color: #000000;">}</span></pre>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/a_xOcp8Anrw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1082</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1082&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powercli-reconnect-vmhosts-after-changing-vcenter-certificates</feedburner:origLink></item>
		<item>
		<title>PowerCLI: Configure iSCSI one-liner</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/SvjN-WiQsNs/</link>
		<comments>http://get-admin.com/blog/?p=1068#comments</comments>
		<pubDate>Mon, 21 Jun 2010 20:33:28 +0000</pubDate>
		<dc:creator>glnsize</dc:creator>
				<category><![CDATA[ESX]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1068</guid>
		<description><![CDATA[While migrating a small environment to vSphere today I ran into my nemesis Host Profiles again. When are they going to Fix these things? The fact that they are incapable of even rudimentary iSCSI configuration is embarrassing. I&#8217;m sure vmware will fix it, but until then I wrote a simple one-liner that will configure iSCSI [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1068"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1068&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>While migrating a small environment to vSphere today I ran into my nemesis Host Profiles again.  When are they going to Fix these things?  The fact that they are incapable of even rudimentary iSCSI configuration is embarrassing.  I&#8217;m sure <strong>vm</strong>ware will fix it, but until then I wrote a simple one-liner that will configure iSCSI on a new host.</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$VMhost</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-VMhost</span> <span style="color: #8b0000;">'ESX01'</span>
<span style="color: #ff4500;">$ChapUserName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">'vmware'</span>
<span style="color: #ff4500;">$ChapPassword</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">'password'</span>
<span style="color: #ff4500;">$SendTargets</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">'192.168.1.1'</span>            

<span style="color: #006400;"># Enable the software ISCSI adapter if not already enabled.</span>
<span style="color: #ff4500;">$VMHostStorage</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-VMHostStorage</span> <span style="color: #000080;">-VMHost</span> <span style="color: #ff4500;">$VMhost</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Set-VMHostStorage</span> <span style="color: #000080;">-SoftwareIScsiEnabled</span> <span style="color: #ff4500;">$True</span>            

<span style="color: #006400;">#sleep while iSCSI starts up</span>
<span style="color: #0000ff;">Start-Sleep</span> <span style="color: #000080;">-Seconds</span> <span style="color: #800080;">30</span>            

<span style="color: #006400;"># By default vSphere will set the Target Node name to iqn.1998-01.com.vmware:&lt;HostName&gt;-&lt;random number&gt; </span>
<span style="color: #006400;"># This script will remove everything after the hostname, set Chap auth, and add a send Target.</span>
<span style="color: #006400;">#</span>
<span style="color: #006400;"># Example iqn.1998-01.com.vmware:esx01-165435 would become iqn.1998-01.com.vmware:esx01</span>
<span style="color: #ff4500;">$VMHostHba</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-VMHostHba</span> <span style="color: #000080;">-VMHost</span> <span style="color: #ff4500;">$VMHost</span> <span style="color: #000080;">-Type</span> <span style="color: #8a2be2;">IScsi</span> <span style="color: #a9a9a9;">|</span>
    <span style="color: #0000ff;">Where-object</span> <span style="color: #000000;">{</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">IScsiName</span> <span style="color: #a9a9a9;">-match</span> <span style="color: #8b0000;">"(?&lt;IQN&gt;iqn.1998-01.com.vmware\:[^-]+)"</span><span style="color: #000000;">}</span> <span style="color: #a9a9a9;">|</span>
    <span style="color: #0000ff;">Set-VMHostHba</span> <span style="color: #000080;">-IScsiName</span> <span style="color: #ff4500;">$Matches</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">IQN</span> <span style="color: #a9a9a9;">|</span>
    <span style="color: #0000ff;">Set-VMHostHba</span> <span style="color: #000080;">-ChapName</span> <span style="color: #ff4500;">$ChapUserName</span> <span style="color: #000080;">-ChapPassword</span> <span style="color: #ff4500;">$ChapPassword</span> <span style="color: #000080;">-ChapType</span> <span style="color: #8b0000;">"Required"</span> <span style="color: #a9a9a9;">|</span>
    <span style="color: #0000ff;">New-IScsiHbaTarget</span> <span style="color: #000080;">-Address</span> <span style="color: #ff4500;">$SendTargets</span> <span style="color: #000080;">-Port</span> <span style="color: #8b0000;">"3260"</span>                

<span style="color: #006400;">#restart the host to make sure everything took</span>
<span style="color: #0000ff;">Restart-VMHost</span> <span style="color: #000080;">-VMHost</span> <span style="color: #ff4500;">$VMHost</span> <span style="color: #000080;">-Confirm:</span><span style="color: #ff4500;">$false</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">out-null</span></pre>
<p>~Glenn</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/SvjN-WiQsNs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1068</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1068&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powercli-configure-iscsi-one-liner</feedburner:origLink></item>
		<item>
		<title>Monitoring for orphaned snapshots left by SMVI</title>
		<link>http://feedproxy.google.com/~r/Get-admin/~3/qlS9GFn3ELM/</link>
		<comments>http://get-admin.com/blog/?p=1059#comments</comments>
		<pubDate>Fri, 18 Jun 2010 00:40:09 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Nagios]]></category>
		<category><![CDATA[NetApp]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Virtulization]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://get-admin.com/blog/?p=1059</guid>
		<description><![CDATA[NetApp&#8217;s SnapManager for Virtual Infrastructure (SMVI) is a great product, but it&#8217;s messy. If it encounters the any error, it seemingly forgets to delete the virtual machine snapshots from the Virtual Infrastructure before dying. To prevent many orphans (I&#8217;ve seen as many as 20 on a single virtual machine) from happening, I created a quick [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1059"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fget-admin.com%2Fblog%2F%3Fp%3D1059&amp;source=glnsize&amp;style=normal&amp;service=bit.ly&amp;service_api=glnsize%3AR_068866ed6e00430b235ea89c721856c2" height="61" width="50" /><br />
			</a>
		</div>
<p>NetApp&#8217;s <a href="http://www.netapp.com/us/products/management-software/snapmanager-virtual.html">SnapManager for Virtual Infrastructure</a> (SMVI) is a great product, but it&#8217;s messy.  If it encounters the any error, it seemingly forgets to delete the virtual machine snapshots from the Virtual Infrastructure before dying.</p>
<p>To prevent many orphans (I&#8217;ve seen as many as 20 on a single virtual machine) from happening, I created a quick Nagios check that simply alerts when it sees them.</p>
<p>This script is very elementary.  It very simply uses a regex to check for any snapshots that match the default SMVI naming convention.  For each one it finds, a counter is incremented.  If any are found, the script returns an error to Nagios, which causes an alert to be sent.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># check_vi_smvi_snapshots.pl - written by Andrew Sullivan, 2010-06-16</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Please report bugs and request improvements at http://get-admin.com/blog/?p=1059</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># A simple script to look for snapshots that match the name pattern that smvi uses.</span>
<span style="color: #666666; font-style: italic;"># We are merely pulling a list of all snapshots, searching for the string &quot;smvi&quot; in </span>
<span style="color: #666666; font-style: italic;"># the name, if it's found, we return a warning condition.  This could lead to a </span>
<span style="color: #666666; font-style: italic;"># &quot;false&quot; positive if it runs while a snapshot series is still ongoing, but since</span>
<span style="color: #666666; font-style: italic;"># the smvi snaps should be very short lived the condidition will not last unless</span>
<span style="color: #666666; font-style: italic;"># the snap is left.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Example:</span>
<span style="color: #666666; font-style: italic;">#   ./check_vi_smvi_snapshots.pl --server your.esx.host --username you --password secret</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> FindBin<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> lib <span style="color: #ff0000;">&quot;$FindBin::Bin/../&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> VMware<span style="color: #339933;">::</span><span style="color: #006600;">VIRuntime</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># substitute the location of your nagios perl library</span>
<span style="color: #000000; font-weight: bold;">use</span> lib <span style="color: #ff0000;">&quot;/usr/lib64/nagios/plugins&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> utils <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">%ERRORS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Opts<span style="color: #339933;">::</span><span style="color: #006600;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Opts<span style="color: #339933;">::</span><span style="color: #006600;">validate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Util<span style="color: #339933;">::</span><span style="color: #000066;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Util<span style="color: #339933;">::</span><span style="color: #006600;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> main <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># the number of smvi snapshots</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$smviSnaps</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># for setting the type of exit we want</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$exitCondition</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># we need MORs for each of the VMs on the host</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$VMs</span> <span style="color: #339933;">=</span> Vim<span style="color: #339933;">::</span><span style="color: #006600;">find_entity_views</span><span style="color: #009900;">&#40;</span> view_type <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'VirtualMachine'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$vm</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$VMs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$vm</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">snapshot</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>			
			<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$childSnapshot</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$vm</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">snapshot</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">snapshotInfo</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">rootSnapshotList</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #0000ff;">$smviSnaps</span> <span style="color: #339933;">+=</span> getSnaps<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$childSnapshot</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">#print $vm-&gt;name . &quot; has no snapshots\n&quot;;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$smviSnaps</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;WARNING - &quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$smviSnaps</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot; SMVI snapshots exist.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$exitCondition</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;WARNING&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;OK - No SMVI snapshots exist.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$exitCondition</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;OK&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	Util<span style="color: #339933;">::</span><span style="color: #006600;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">exit</span> <span style="color: #0000ff;">$ERRORS</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$exitCondition</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> getSnaps <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$snapshotTree</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$snapcount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># uncomment for debugging</span>
	<span style="color: #666666; font-style: italic;">#print &quot;Found snap: &quot; . $snapshotTree-&gt;{name} . &quot;\n&quot;;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">$snapshotTree</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>name<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/smvi/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$snapcount</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$snapshotTree</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">childSnapshotList</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$childSnapshot</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$snapshotTree</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">childSnapshotList</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #0000ff;">$snapcount</span> <span style="color: #339933;">+=</span> getSnaps<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$childSnapshot</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$snapcount</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;ve set the check to execute once an hour in my environment, as I don&#8217;t feel that granularity finer than that is needed&#8230;an hour&#8217;s worth of change is ok for an SMVI snapshot for me.</p>
<img src="http://feeds.feedburner.com/~r/Get-admin/~4/qlS9GFn3ELM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://get-admin.com/blog/?feed=rss2&amp;p=1059</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://get-admin.com/blog/?p=1059&amp;utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=monitoring-for-orphaned-snapshots-left-by-smvi</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 1.000 seconds -->
