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

<channel>
	<title>PeetersOnline &#187; Stat</title>
	<atom:link href="http://www.peetersonline.nl/index.php/tag/stat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peetersonline.nl</link>
	<description>Using Powershell for (virtually) everything!</description>
	<lastBuildDate>Thu, 27 May 2010 08:01:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Examine VMware CPU Ready Times with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/examine-vmware-cpu-ready-times-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/examine-vmware-cpu-ready-times-with-powershell/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:26:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Stat]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=398</guid>
		<description><![CDATA[When your (VMware) consolidation ratios are becoming high, it might be smart to keep an eye on your vm&#8217;s CPU Ready Times. Unfortunately, by default, the VI Client will only show realtime ready time statistics. Plus you&#8217;d have to look at each vm individually. Thank God VMware for the PowerCLI! Read this document for more [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>When your (<a href="http://www.vmware.com/" target='_blank'>VMware</a>) consolidation ratios are becoming high, it might be smart to keep an eye on your vm&#8217;s CPU Ready Times. Unfortunately, by default, the VI Client will only show realtime ready time statistics. Plus you&#8217;d have to look at each vm individually. Thank <del datetime="2009-06-12T13:20:49+00:00">God</del> <a href="http://www.vmware.com/" target='_blank'>VMware</a> for the <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a>! Read <a href="http://viops.vmware.com/home/docs/DOC-1404.pdf;jsessionid=C2335915887A860FD97EA727CDC5DC15">this document </a>for more information on how to interpret the results.</p>
<p><span id="more-398"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Variables</span>
<span style="color: #800080;">$OutFile</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;D:\Scripts\ReadyTimes.csv&quot;</span>
<span style="color: #800080;">$VIServer</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;MyVIServer.domain.local&quot;</span>
&nbsp;
<span style="color: #008000;"># Connect to Virtual Center</span>
<span style="color: #800080;">$VI</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$VIServer</span>
&nbsp;
<span style="color: #800080;">$myCol</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VM</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>VM <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># Gather Stats</span>
		<span style="color: #800080;">$Ready</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>Stat <span style="color: pink;">-</span>Stat Cpu.Ready.Summation <span style="color: pink;">-</span>RealTime
		<span style="color: #800080;">$Used</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>Stat <span style="color: pink;">-</span>Stat Cpu.Used.Summation <span style="color: pink;">-</span>RealTime
		<span style="color: #800080;">$Wait</span> <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>Stat <span style="color: pink;">-</span>Stat Cpu.Wait.Summation <span style="color: pink;">-</span>RealTime
		<span style="color: #0000FF;">For</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$a</span> <span style="color: pink;">=</span> <span style="color: #000000;">0</span>; <span style="color: #800080;">$a</span> <span style="color: #FF0000;">-lt</span> <span style="color: #800080;">$VM</span>.NumCpu; <span style="color: #800080;">$a</span><span style="color: pink;">++</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$myObj</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> VMHost<span style="color: pink;">,</span> VM<span style="color: pink;">,</span> Instance<span style="color: pink;">,</span> <span style="color: pink;">%</span>RDY<span style="color: pink;">,</span> <span style="color: pink;">%</span>USED<span style="color: pink;">,</span> <span style="color: pink;">%</span>WAIT
			<span style="color: #800080;">$myObj</span>.VMHost <span style="color: pink;">=</span> <span style="color: #800080;">$VMHost</span>.Name
			<span style="color: #800080;">$myObj</span>.VM <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span>.Name
			<span style="color: #800080;">$myObj</span>.Instance <span style="color: pink;">=</span> <span style="color: #800080;">$a</span>
			<span style="color: #800080;">$myObj</span>.<span style="color: #800000;">&quot;%RDY&quot;</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Ready</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Instance <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$a</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Value <span style="color: #008080; font-style: italic;">-Average</span><span style="color: #000000;">&#41;</span>.Average<span style="color: #000000;">&#41;</span><span style="color: pink;">/</span><span style="color: #000000;">200</span><span style="color: pink;">,</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$myObj</span>.<span style="color: #800000;">&quot;%USED&quot;</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Used</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Instance <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$a</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Value <span style="color: #008080; font-style: italic;">-Average</span><span style="color: #000000;">&#41;</span>.Average<span style="color: #000000;">&#41;</span><span style="color: pink;">/</span><span style="color: #000000;">200</span><span style="color: pink;">,</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$myObj</span>.<span style="color: #800000;">&quot;%WAIT&quot;</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$Wait</span> <span style="color: pink;">|</span> <span style="color: #0000FF;">Where</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Instance <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$a</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> <span style="color: #008080; font-style: italic;">-Property</span> Value <span style="color: #008080; font-style: italic;">-Average</span><span style="color: #000000;">&#41;</span>.Average<span style="color: #000000;">&#41;</span><span style="color: pink;">/</span><span style="color: #000000;">200</span><span style="color: pink;">,</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$myCol</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$myObj</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #008080; font-weight: bold;">Clear-Variable</span> Ready <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue 
		<span style="color: #008080; font-weight: bold;">Clear-Variable</span> Wait <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue 
		<span style="color: #008080; font-weight: bold;">Clear-Variable</span> Used <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue 
		<span style="color: #008080; font-weight: bold;">Clear-Variable</span> myObj <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$false</span>
&nbsp;
<span style="color: #008000;"># Export and launch output</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Export-Csv</span> <span style="color: #800080;">$OutFile</span>
<span style="color: #008080; font-weight: bold;">Invoke-Item</span> $OutFile</pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/examine-vmware-cpu-ready-times-with-powershell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>VMware Stats Oneliner</title>
		<link>http://www.peetersonline.nl/index.php/vmware/vmware-stats-oneliner/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/vmware-stats-oneliner/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 13:53:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Oneliners]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Stat]]></category>
		<category><![CDATA[VI Toolkit]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/index.php/vmware/vmware-stats-oneliner/</guid>
		<description><![CDATA[Today&#8217;s oneliner is a nifty little function that reports the average CPU and Memory usage for one or more of your VMs, calculated over the last x hours: function Get-VMStat { param( $VM,[Int32]$Hours = 1 )  $VM &#124; Sort Name &#124;  Select Name, @{N=&#8221;CPU&#8221;;E={[Math]::Round((($_ &#124;  Get-Stat -Stat cpu.usage.average -Start (Get-Date).AddHours(-$Hours) -IntervalMins 5 -MaxSamples ($Hours*12) &#124; [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s oneliner is a nifty little function that reports the average CPU and Memory usage for one or more of your VMs, calculated over the last x hours:</p>
<blockquote><p>function Get-VMStat<br />
{<br />
param( $VM,[Int32]$Hours = 1 )<br />
 $VM | Sort Name |<br />
 Select Name, @{N=&#8221;CPU&#8221;;E={[Math]::Round((($_ |<br />
 Get-Stat -Stat cpu.usage.average -Start (Get-Date).AddHours(-$Hours) -IntervalMins 5 -MaxSamples ($Hours*12) |<br />
 Measure-Object Value -Average).Average),2)}}, @{N=&#8221;MEM&#8221;;E={[Math]::Round((($_ |<br />
 Get-Stat -Stat mem.usage.average -Start (Get-Date).AddHours(-$Hours) -IntervalMins 5 -MaxSamples ($Hours*12) |<br />
 Measure-Object Value -Average).Average),2)}}<br />
}</p></blockquote>
<p>A great way to use it is like this:</p>
<blockquote><p>Get-VMStat (Get-VM) -Hours 4 | Where {$_.CPU -gt 50 -or $_.MEM -gt 75}</p></blockquote>
<p>I&#8217;m sure you can figure out what that does. Be the first to give the correct answer in the comments to win everlasting glory! (or at least until the next oneliner&#8230;)</p>
<p>Enjoy!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.peetersonline.nl/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/vmware-stats-oneliner/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
