<?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>vmweaver.com &#187; Virtualization</title>
	<atom:link href="http://vmweaver.com/index.php/category/technology/virtualization/feed/" rel="self" type="application/rss+xml" />
	<link>http://vmweaver.com</link>
	<description>Mindless ramblings of a geek...</description>
	<lastBuildDate>Thu, 06 Oct 2011 20:42:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Zen and the Mystical Art of Candidacy Analysis</title>
		<link>http://vmweaver.com/index.php/2009/03/zen-and-the-mystical-art-of-candidacy-analysis/</link>
		<comments>http://vmweaver.com/index.php/2009/03/zen-and-the-mystical-art-of-candidacy-analysis/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 03:54:34 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[candidacy analysis]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=116</guid>
		<description><![CDATA[Okay so maybe there is no Zen, nor is it really &#8220;mystical&#8221;.  One of the MANY challenges we faced while trying to implement a brand-spanking-new virtualization infrastructure was to put together some type of guidance for our server admin teams to help them determine if existing systems would &#8220;live&#8221; happily in our new environment. After reading recommendations from [...]]]></description>
			<content:encoded><![CDATA[<p>Okay so maybe there is no Zen, nor is it really &#8220;mystical&#8221;. </p>
<p>One of the MANY challenges we faced while trying to implement a brand-spanking-new virtualization infrastructure was to put together some type of guidance for our server admin teams to help them determine if existing systems would &#8220;live&#8221; happily in our new environment.</p>
<p>After reading recommendations from VMware, digging through Microsoft Management Packs for Operations Manager, etc., it didn&#8217;t seem that any of those really fit our needs nor did they make much sense.</p>
<p>So we happen to use Operations Manager to collect performance data on our Windows-based servers, but there is a TON of data.</p>
<p>We also had to make sure that the tools we were using (Operations Manager) didn&#8217;t aggregate our data.  We NEEDED to have granular data for our entire 3 month look-back period.  We just didn&#8217;t like the idea of averaging averages, so we have data points every 5 or 15 minutes (depending on the counter) for 90 days.  One of the early reports we developed let admins specify the peak usage times so that the performance analysis could be tailored for specific systems.</p>
<p>Now we have all of this data but how do we look at it?  How do we know what&#8217;s important?  What recommendations from VMware and MS do we use and which ones do we throw away?</p>
<p>Several of the deficiencies we saw with most tools are:</p>
<ol>
<li>They average entire periods of time (a day, a week, a month) with no regard for peak usage times</li>
<li>They use aggregated data (kind of like above)</li>
<li>They assume that &#8220;CPU %&#8221; means the same thing for all systems</li>
</ol>
<p>So now we have to look only at peak times for specific servers.  Wow..that can be a VERY daunting task unless you make SOME assumptions.  That&#8217;s exactly what we did.</p>
<p>We know that not ALL systems will have the same usage patterns, but generally our systems will be the busiest during normal business hours at our corporate data center.  So, that would be Monday &#8211; Friday, 8am-5pm CST.  Well, we also have people using our systems on the east and west coasts, so if we move our &#8220;peak&#8221; time to 7am-7pm CST, we should cover most of the usage we wish to capture.</p>
<p>You  may be asking why not just take all data points and be done with it&#8230; I know *WE* did.</p>
<p>It would certainly have been easier, but far less accurate.  To demonstrate this, think about this:</p>
<ul>
<li>A system has a CPU utilization of 75% all the time during peak usage times</li>
<li>This same system has a CPU utilization of 10% during off-peak times</li>
<li>This system has a CPU utilization of 10% during the ENTIRE weekend</li>
</ul>
<p>Okay, so if we take the mean average (the normal practice) we get something in the range of&#8230;well.. I am not gonna do the math, but it is WAY less than 75%.  We THEN thought, well&#8230; why not just take the highest or maximum measurement for the entire period and plan for that?  That doesn&#8217;t work out so well either if you have systems that don&#8217;t do ANYTHING, then a virus scan kicks off and pegs the CPU for 3o minutes.  This greatly throws our performance footprint off.  So now we have to find a happy sweet-spot for evaluating performance.</p>
<p>After mulling through all of our options and thinking about what types of data were REALLY helpful in this process, we decided to do a &#8220;Top 20% Average&#8221;.  I know it sounds a little strange, but it is pretty straight-forward. How did we come up with this number?  Well, we had to pick a number and threw some others around and this one seems to work, so we stuck with it.  The calculation is pretty simple:</p>
<ol>
<li>Take all of your data points</li>
<li>Sort them High to Low</li>
<li>Take the top 20% of your values and average them</li>
</ol>
<p>This gives us a nice look at what our systems do when they are operating at or near their highest loads.  The benefit of having a Top 20% Average and its normal average is that the greater the difference between the two, the &#8220;more spiky&#8221; the performance is.  As the numbers get closer and closer we can see that our systems are more consistently busy during our peak usage time.</p>
<p>The two most important things we need to be looking at are CPU and Memory utilization since those are often the most limiting resources in our environment.  Of less importance to us were Disk IO and Network IO because we were really looking at &#8220;low hanging fruit&#8221; types of systems and NORMALLY if a system is disk or network heavy, CPU utilization will also shoot up.</p>
<p>So now we have this notion of Top 20% Average (T20 Average) and Average, but what are we actually analyzing?</p>
<h2><span style="text-decoration: underline;">Not So Normal CPU Usage</span></h2>
<p>Well, we can&#8217;t just look at CPU Utilization Percent!  Why, you may ask? Well CLEARLY the following are not equivalent:</p>
<ul>
<li>1 CPU &#8211; 700MHz system running 75% utilization</li>
<li>4 CPU &#8211; 2.2 GHz system running 20% utilization</li>
</ul>
<p>Many tools used to evaluate this type of data look at Total CPU Percent Utilization.  This would mean our 1 CPU system has a larger processor footprint than our 4 CPU system.  This doesn&#8217;t really make sense.</p>
<p>One of the interesting strategies VMware presents in some of their documentation is this idea of a &#8220;normalized&#8221; CPU.   Basically this is kind of calculating how many megahertz  a system uses instead of using a percentage (which is relative to how many horses are under the hood).  While this isn&#8217;t entirely accurate, it does help us create high-water marks for a normalized calculation.</p>
<p>In the above example, our 1CPU system would have a normalized CPU usage of :</p>
<ul>
<li>1 CPU x 700MHz  x .75 = <strong>525MHz</strong></li>
</ul>
<p>Our 4CPU system would normalize to :</p>
<ul>
<li>4 CPU x 2200MHz x .20 = <strong>1760MHz</strong></li>
</ul>
<p>It is MUCH easier to compare the 2 of them now and to see which one will probably have a larger processor footprint.  I do realize that it doesn&#8217;t really take into account performance of multi-threaded applications and such, but it does a pretty good job.</p>
<p>So, how do we get all that info to calculate it? Well, we also happen to have SMS or SCCM available to collect configuration information about our systems.  This enables us to create some custom database views that contained system information regarding CPU Speeds, number of CPUs,  Hyperthreading configuration, etc.  We needed to have info on Hyper-Threading enabled hardware because Windows actually reports those &#8220;HT&#8221; processors as physical processors.  Unfortunately a  HT processor doesn&#8217;t really have the same performance as a TRUE physical processor.</p>
<p>To get around this, we figure a HT Processor is about a half of a physical processor.  So if our 4CPU system above is really a 2CPU system with HT, it would look like this:</p>
<ul>
<li>2 CPU x 2200MHz x .20 = <strong>880MHz</strong></li>
<li>2 CPU x .5 (because they are HT)  x 2200MHz x .20 = <strong>440MHz</strong></li>
<li>Total Normalized CPU usage is <strong>1320MHz</strong></li>
</ul>
<p>I hope I did an okay job of explaining it.  If not, please let me know.</p>
<h2><span style="text-decoration: underline;">Memory and Commitment</span></h2>
<p>Memory is VERY easy to evaluate compared to CPU numbers as it is already normalized (kinda).  We will use the same methodologies for memory as we did for CPU with respect to Average Values and peak times.  When looking at memory counters, we are interested in finding out how much memory our systems are using, not how much is free, or the percent free or anything like that.</p>
<p>As Microsoft calls it, we need the &#8220;<strong>Committed Bytes in Use</strong>&#8221; counter.   I don&#8217;t think Operations Manager collects this info by default, so you may need to start collecting it to do this type of analysis.</p>
<p>Other than using the right counter it is pretty much the same as CPU.</p>
<h2><span style="text-decoration: underline;">Disk and Network Stuff</span></h2>
<p>While we DO care about network and disk throughput, they typically will be weighted much less than CPU and memory utilization when looking at the overall analysis.  If you are looking at virtualizing some beefy SQL or Exchange systems, then these will become MUCH more important, but probably still following memory and cpu.</p>
<p>We use the same Average calculations as we do for CPU and Memory, but we will look at the disk counter &#8220;Disk Bytes per Second&#8221;  for this analysis and<br />
&#8220;Total Bytes per second&#8221;(I think) for the network counter.  It MAY be important to eliminate loopback adapters in the query for network data, but most of the time our data comes back with numbers that are WAY below our thresholds for candidacy on even relatively busy systems.</p>
<h2><span style="text-decoration: underline;">Whew!!!</span></h2>
<p>So, I made it through this in one fell swoop.  I am SURE that it isn&#8217;t written perfectly, but I wanted to get my thoughts down on this topic.  If you have any questions about it or recommendations&#8230;.. PLEASE comment and open a dialogue.</p>
<p>Thanks for making it through this&#8230; and good luck.</p>
<p>&#8211; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2009/03/zen-and-the-mystical-art-of-candidacy-analysis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get-HACapacity</title>
		<link>http://vmweaver.com/index.php/2009/02/get-hacapacity/</link>
		<comments>http://vmweaver.com/index.php/2009/02/get-hacapacity/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 02:26:51 +0000</pubDate>
		<dc:creator>Mark A. Weaver</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[capacity]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[ha]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://vmweaver.com/?p=46</guid>
		<description><![CDATA[This script will calculate the HighAvailability capacity of a VMware ESX Cluster. ### Written by Mark A. Weaver ## Date: 7/27/2008 ## Version: 1.0 ## Website: www.vmweaver.com ## ## Call this function and pass in -ServerName -ClusterName ## Output should be an object containing the information ## ## Feel free to modify as needed to [...]]]></description>
			<content:encoded><![CDATA[<p>This script will calculate the HighAvailability capacity of a VMware ESX Cluster.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">### Written by Mark A. Weaver</span>
<span style="color: #008000;">##  Date: 7/27/2008</span>
<span style="color: #008000;">##  Version: 1.0</span>
<span style="color: #008000;">##  Website: www.vmweaver.com</span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##  Call this function and pass in -ServerName  -ClusterName</span>
<span style="color: #008000;">##  Output should be an object containing the information</span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##  Feel free to modify as needed to suit your needs, but please keep this header</span>
<span style="color: #008000;">##</span>
<span style="color: #008000;">##  Thanks  -- Mark</span>
&nbsp;
<span style="color: #0000FF;">function</span> Get<span style="color: pink;">-</span>HACapacity<span style="color: #000000;">&#40;</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ServerName</span><span style="color: pink;">,</span>
<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$ClusterName</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$ServerName</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-and</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$ClusterName</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># These booleans tell me if I am using the VMware default memory and cpu reservations for the cluster.</span>
			<span style="color: #800080;">$DASMemDefault</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
			<span style="color: #800080;">$DASCPUDefault</span> <span style="color: pink;">=</span> <span style="color: #800080;">$True</span>
&nbsp;
		<span style="color: #008000;"># The following numbers are derived from VMware published numbers for memory overhead.</span>
		<span style="color: #008000;"># I have dropped them into arrays using the number of vCPUs as an index to get the correct constant.</span>
		<span style="color: #008000;"># This is why you will notice only [1], [2], and [4] have non-zero values</span>
		<span style="color: #008000;"># These constants are used later on when calculating Memory Reserve.</span>
			<span style="color: #800080;">$MemConst32</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">3.262</span><span style="color: pink;">,</span> <span style="color: #804000;">5.769059</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">6.77933</span>
			<span style="color: #800080;">$MemConst64</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">3.2678</span><span style="color: pink;">,</span> <span style="color: #804000;">5.79251</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">6.82622</span>
			<span style="color: #800080;">$MemBase32</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">87.56</span><span style="color: pink;">,</span> <span style="color: #804000;">108.73</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">146.75</span>
			<span style="color: #800080;">$MemBase64</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">107.54</span><span style="color: pink;">,</span> <span style="color: #804000;">146.41</span><span style="color: pink;">,</span> <span style="color: #804000;">0</span><span style="color: pink;">,</span> <span style="color: #804000;">219.82</span>
&nbsp;
		<span style="color: #008000;"># Initialize some Variables</span>
			<span style="color: #800080;">$MaxMemRes</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
			<span style="color: #800080;">$MacNumCPU</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
			<span style="color: #800080;">$MaxCPUResVM</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span>
			<span style="color: #800080;">$VMCount</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
		<span style="color: #008000;"># define default memory and cpu reservation</span>
			<span style="color: #800080;">$DASMinMHz</span> <span style="color: pink;">=</span> <span style="color: #804000;">256</span>
			<span style="color: #800080;">$DASMinMemory</span> <span style="color: pink;">=</span> <span style="color: #804000;">256</span>
&nbsp;
			<span style="color: #800080;">$viServerName</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ServerName</span>
			<span style="color: #800080;">$viClusterName</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ClusterName</span>
&nbsp;
		<span style="color: #008000;"># Connect to the VirtualCenter Server and get some info</span>
			<span style="color: #800080;">$viServer</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800080;">$viServerName</span>
			<span style="color: #800080;">$viCluster</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>cluster <span style="color: #800080;">$viClusterName</span>
			<span style="color: #800080;">$viHosts</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>vmhost <span style="color: pink;">-</span>location <span style="color: #800080;">$viCluster</span>
			<span style="color: #800080;">$viClusterV</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>view <span style="color: #800080;">$viCluster</span>.ID
&nbsp;
		<span style="color: #008000;"># Get the &quot;Resources&quot; Resource Pool from the cluster.</span>
		<span style="color: #008000;"># This gives us the Reservation Pools for Memory and CPU</span>
			<span style="color: #800080;">$viResGroup</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>ResourcePool <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;Resources&quot;</span> <span style="color: pink;">-</span>Location <span style="color: #800080;">$viCluster</span>
			<span style="color: #800080;">$viCPURes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viResGroup</span>.CpuReservationMHz
			<span style="color: #800080;">$viMemRes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viResGroup</span>.MemReservationMB
			<span style="color: #800080;">$viHostCount</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viClusterV</span>.Summary.NumHosts
&nbsp;
		<span style="color: #008000;"># Get HA cluster configuration information</span>
			<span style="color: #800080;">$viHostFailures</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viClusterV</span>.Configuration.DasConfig.FailoverLevel
&nbsp;
		<span style="color: #008000;"># Get a list of options that may be configured at the clusters level</span>
		<span style="color: #008000;"># We are looking for whether or not the default memory and cpu</span>
		<span style="color: #008000;">#  reservations have been overridden</span>
			<span style="color: #800080;">$viDASOptions</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viClusterV</span>.Configuration.DASConfig.Option
			<span style="color: #800080;">$viVMs</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>vm <span style="color: pink;">-</span>Location <span style="color: #800080;">$viCluster</span>
&nbsp;
		<span style="color: #008000;"># Is Adminisssion Control enabled on the cluster?</span>
			<span style="color: #800080;">$viClusterControl</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viClusterV</span>.Configuration.DASConfig.AdmissionControlEnabled	
&nbsp;
		<span style="color: #008000;"># See if das.vmMemoryMinMB key is defined and grab its value</span>
		<span style="color: #008000;"># See if das.vmCpuMinMHZ key is defined and grab its value</span>
			<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$viDASoptions</span>.Count <span style="color: #FF0000;">-ne</span> <span style="color: #804000;">0</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;">$viDASOption</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$viDASOptions</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$viDASOption</span>.Key <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;das.vmMemoryMinMB&quot;</span><span style="color: #000000;">&#41;</span>
					<span style="color: #000000;">&#123;</span>
						<span style="color: #800080;">$DASMemDefault</span> <span style="color: pink;">=</span> <span style="color: #800080;">$False</span>
					<span style="color: #800080;">$DASMinMemory</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viDASOption</span>.Value <span style="color: #000000;">&#125;</span>
&nbsp;
					<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$viDASOption</span>.Key <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;das.vmCpuMinMHz&quot;</span><span style="color: #000000;">&#41;</span>
					<span style="color: #000000;">&#123;</span>
						<span style="color: #800080;">$DASCPUDefault</span> <span style="color: pink;">=</span> <span style="color: #800080;">$False</span>
					<span style="color: #800080;">$DASMinMHz</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viDASOption</span>.Value <span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #008000;"># Let's go through every VM and see what the maximum CPU and Memory reservation is.</span>
		<span style="color: #008000;"># We will also get a count of powered on VMs.</span>
		<span style="color: #008000;"># When we hit a maximum reservation, save the machine name that set that maximum</span>
			<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$viVM</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$viVMs</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$NumCPU</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viVm</span>.NumCPU
				<span style="color: #800080;">$VMMem</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viVm</span>.MemoryMB
				<span style="color: #800080;">$MemRes</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
				<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$viVM</span>.PowerState <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;PoweredOn&quot;</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$VMCount</span> <span style="color: pink;">+=</span> <span style="color: #804000;">1</span>
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #008000;"># Get the VM-view and determine if the current guest CPU or memory reservations configured</span>
			<span style="color: #800080;">$vmView</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>view <span style="color: #800080;">$viVM</span>.ID
			<span style="color: #800080;">$vmViewCPURes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmView</span>.ResourceConfig.CpuAllocation.Reservation
			<span style="color: #800080;">$vmViewMemRes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmView</span>.ResourceConfig.MemoryAllocation.Reservation
&nbsp;
			<span style="color: #008000;"># If no reservations are set at the VM level, calculate the memory reservation.</span>
			<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmViewMemRes</span> <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMMem</span> <span style="color: #FF0000;">-le</span> <span style="color: #804000;">256</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$MemRes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$MemConst64</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$NumCpu</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$MemBase64</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$NumCPU</span><span style="color: #000000;">&#93;</span>
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0000FF;">else</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$viVM</span>.Guest.OSFullName <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select-String</span> <span style="color: #800000;">&quot;64-bit&quot;</span><span style="color: #000000;">&#41;</span>.Matches.Count<span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-ge</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>
					<span style="color: #000000;">&#123;</span>
						<span style="color: #800080;">$MemRes</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMMem</span> <span style="color: pink;">/</span> <span style="color: #804000;">256</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">*</span> <span style="color: #800080;">$MemConst64</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$NumCPU</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$MemBase64</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$NumCPU</span><span style="color: #000000;">&#93;</span>
					<span style="color: #000000;">&#125;</span>
					<span style="color: #0000FF;">else</span>
					<span style="color: #000000;">&#123;</span>
						<span style="color: #800080;">$MemRes</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMMem</span> <span style="color: pink;">/</span> <span style="color: #804000;">256</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">*</span> <span style="color: #800080;">$MemConst32</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$NumCPU</span><span style="color: #000000;">&#93;</span> <span style="color: pink;">+</span> <span style="color: #800080;">$MemBase32</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$NumCPU</span><span style="color: #000000;">&#93;</span>
					<span style="color: #000000;">&#125;</span>
				<span style="color: #000000;">&#125;</span>
&nbsp;
				<span style="color: #800080;">$MemRes</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$DASMinMemory</span>
			<span style="color: #000000;">&#125;</span>																			
&nbsp;
			<span style="color: #0000FF;">else</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$MemRes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmViewMemRes</span> 									
&nbsp;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #008000;">#Figure out if the current VM holds the highest reservation so far</span>
&nbsp;
				<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$vmViewCPURes</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$DASMinMHz</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$DASMinMHz</span> <span style="color: pink;">=</span> <span style="color: #800080;">$vmViewCPURes</span>
					<span style="color: #800080;">$MaxCPUResVM</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viVM</span>.Name
				<span style="color: #000000;">&#125;</span>			
&nbsp;
				<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$MemRes</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$MaxMemRes</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$MaxMemRes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$MemRes</span>
					<span style="color: #800080;">$MaxMemResVM</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viVM</span>.Name
				<span style="color: #000000;">&#125;</span>
&nbsp;
				<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$NumCPU</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$MaxNumCPU</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #800080;">$MaxNumCPU</span> <span style="color: pink;">=</span> <span style="color: #800080;">$NumCPU</span>
					<span style="color: #800080;">$MaxCPUNumVM</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viVM</span>.Name
				<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$MaxCPUResVM</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #800080;">$MaxCPUResVM</span> <span style="color: pink;">=</span> <span style="color: #800080;">$MaxCPUNumVM</span> <span style="color: #000000;">&#125;</span>			
&nbsp;
		<span style="color: #800080;">$MaxCPURes</span> <span style="color: pink;">=</span> <span style="color: #800080;">$MaxNumCPU</span> <span style="color: pink;">*</span> <span style="color: #800080;">$DASMinMHz</span>
&nbsp;
		<span style="color: #008000;"># Calculate the VM Capacity for the cluster based on memory and cpu reservations.</span>
			<span style="color: #800080;">$ClusterVMCapacityMEM</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Truncate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$viMemRes</span> <span style="color: pink;">/</span> <span style="color: #800080;">$MaxMemRes</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#40;</span> <span style="color: #800080;">$viHostCount</span> <span style="color: pink;">-</span> <span style="color: #800080;">$viHostFailures</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">/</span> <span style="color: #800080;">$viHostCount</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #800080;">$ClusterVMCapacityCPU</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>Math<span style="color: #000000;">&#93;</span>::Truncate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$viCPURes</span> <span style="color: pink;">/</span> <span style="color: #800080;">$MaxCPURes</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">*</span> <span style="color: #000000;">&#40;</span> <span style="color: #800080;">$viHostCount</span> <span style="color: pink;">-</span> <span style="color: #800080;">$viHostFailures</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">/</span> <span style="color: #800080;">$viHostCount</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
&nbsp;
			<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$ClusterVMCapacityMEM</span> <span style="color: #FF0000;">-lt</span> <span style="color: #800080;">$ClusterVMCapacityCPU</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$ClusterVMCapacity</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ClusterVMCapacityMEM</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0000FF;">else</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #800080;">$ClusterVMCapacity</span> <span style="color: pink;">=</span> <span style="color: #800080;">$ClusterVMCapacityCPU</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #008000;"># Create an object to return</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Object
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> ClusterCPURes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viCPURes</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> DefaultCPURes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$DASCPUDefault</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MinCPURes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$DASMinMHz</span>
		   <span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MaxCPUNumVM <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MaxCPUNumVM</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MaxCPURes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MaxCPURes</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MaxCPUResVM <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MaxCPUResVM</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MaxCPUs <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MaxNumCPU</span>
			<span style="color: #800080;">$CPUObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> VMCapacityCPU <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$ClusterVMCapacityCPU</span>
&nbsp;
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Object
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> ClusterMemRes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viMemRes</span>
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> DefaultMemRes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$DASMemDefault</span>
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MinMemRes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$DASMinMemory</span>
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MaxMemRes <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MaxMemRes</span>
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> MaxMemResVM <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MaxMemResVM</span>
			<span style="color: #800080;">$MemObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> VMCapacityMem <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$ClusterVMCapacityMEM</span>
&nbsp;
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Object
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> AdmissionControl <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viClusterControl</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> CPU <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$CPUObj</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> FailoverHosts <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viHostFailures</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> HostCount <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viHostCount</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> Memory <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$MemObj</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> RunningVMs <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$VMCount</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> VIServer <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viServerName</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> VICluster <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$viClusterName</span>
			<span style="color: #800080;">$OutObj</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Add-Member</span> <span style="color: pink;">-</span><span style="color: #008080; font-weight: bold;">type</span> NoteProperty <span style="color: #008080; font-style: italic;">-name</span> VMCapacity <span style="color: #008080; font-style: italic;">-value</span> <span style="color: #800080;">$ClusterVMCapacity</span>	
&nbsp;
			<span style="color: #0000FF;">return</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$outObj</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #008000;"># Write usage info</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;-------------------------------------&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;Get-HACapacity.ps1 Usage:&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span><span style="color: #000000;">&#40;</span> <span style="color: #800000;">&quot;You must specify the following parameters: &quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;     '-ServerName '  where  is the name of the VirtualCenter Server&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span><span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;     '-ClusterName '  where  is the name of the cluster to query&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Let me know if you have any problems with it or would like more info..</p>
<p>&#8211; Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://vmweaver.com/index.php/2009/02/get-hacapacity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

