Here's what I decided to go with (for now): (snipped)
==============================
$ESXHost = "- - - - "
$ESX = Get-VMHost $ESXHost
$ESXHostTotalCPUMHz = $ESX.CPUTotalMHz
$ESXHostNumCPU = $ESX.NumCPU
$ESXHostCPUMHz = $ESX.CPUTotalMHz / $ESX.NumCPU
ForEach ($VM_Server in (Get-VM))
{
$VMname = $VM_Server
$VMConfiguredMemMB = $VMname.MemoryMB
$VMConfiguredCPUMHz = $VMname.NumCPU * $ESXHostCPUMHz
$MonthlyMemUsageStats=get-stat -entity $VMname -stat mem.usage.average
-Start $StartOfMonth -Finish $EndOfMonth -IntervalMins 120
$MonthlyCPUUsageStats=get-stat -entity $VMname -stat
cpu.usageMHz.average -Start $StartOfMonth -Finish $EndOfMonth
-IntervalMins 120
$MaxAvgMemUsedPct= [system.math]::round(($MonthlyMemUsageStats |
Measure-Object -Property Value -Maximum).maximum,2)
$MaxAvgMemUsedMB= [system.math]::round(($MaxAvgMemUsedPct / 100.00) *
$VMConfiguredMemMB,0)
$MemOverCommitMB= [system.math]::round(($VMConfiguredMemMB /
$MaxAvgMemUsedMB),2)
$MaxAvgCPUUsedMHz= [system.math]::round(($MonthlyCPUUsageStats |
Measure-Object -Property Value -Maximum).maximum,2)
$CPUOverCommitMHz= [system.math]::round(($VMConfiguredCPUMHz /
$MaxAvgCPUUsedMHz),2)
==============================
This gives me output like this:
<VM NAME>: mem allocated: 4096MB. Highest AVG Mem [MB]: 1198MB;
Overcommit= 3.42
<VM NAME>: CPU MHz allocated: 4528MHz. Highest AVG CPU [MHz]: 1059MHz;
Overcommit= 4.28
And I'm thinking that any memory overcommit of 1.5+ will be reported
(more than 50% memory unneeded is too much). Still debating a CPU
overcommit percentage .... maybe 3? Two might not be enough for a really
heavy usage period ...
Also still debating how to relate this to reservations/limits for mem
and CPU, or if we should even set them ...
On 1/10/2012 10:12 AM, Mike Leone wrote:
I am working on a PowerCLI (Powershell with VMware extension) script
that I want to use to determine memory and vCPU over-commit - i.e.,
that I have allocated too much vCPU or memory to a VM. I can figure
out the memory easily enough - I take the maximum of the last 30 days
worth of 2 hour intervals of "mem.usage.stat" counter, and compare
that to the amount of memory allocated to the VM (MemoryMB). If
MemoryMB / Max MemUsed is more than 2.0, then I've allocated more than
twice what the memory needs of this VM are (based on the last 30 days
usage), and I should be able to drop down the allocated memory, still
have enough of a buffer for unusual needs for the VM, and save some
cluster resources as a reserve.
But how can I get a similar result for vCPU? For example, if I have a
VM with 4 vCPUs, is there any way to determine that I can get along
just fine with 2 vCPUs, based on max CPU usage for the last 30 days?
What counters do I look at, and how do they relate to the number of
vCPUs allocated? On the VMware forums, I've been advised like this:
Once you have collected your max CPU usage stat I would do the following.
CPUsageMax * ( CurrentCPUCount / NewCPUCount)
If output is < 85 reduce by 1 vCPU. Loop this to see if you need to
remove more then one vCPU. Same equation for adding vCPUs
For instance. You have 3 vCPUs at 50% utilisation.
50 * (3/2) = 75
In this case you can drop down to one vCPU.
Thoughts on this methodology? I know that there are commercial
programs to analyze your VMware cluster, and tell you these things,
and even adjust them, but we don't have the budget for Capacity IQ. So
I'm trying for a "some improvement is better than no improvement". Is
there a better way to estimate this? I have a few VMs with 4 vCPUs,
and while I'm sure I can knock a CPU off those VMs, I need some
numbers to back me up, and to show that removing one vCPU won't
negatively impact that VM too much ...
Thanks, and sorry for the OT.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin