PeetersOnline.nl
Examine VMware CPU Ready Times with Powershell
When your (VMware) consolidation ratios are becoming high, it might be smart to keep an eye on your vm’s CPU Ready Times. Unfortunately, by default, the VI Client will only show realtime ready time statistics. Plus you’d have to look at each vm individually. Thank God VMware for the PowerCLI! Read this document for more information on how to interpret the results.
# Variables $OutFile = "D:\Scripts\ReadyTimes.csv" $VIServer = "MyVIServer.domain.local" # Connect to Virtual Center $VI = Connect-VIServer $VIServer $myCol = @() ForEach ($VMHost in (Get-VMHost | Sort Name)) { ForEach ($VM in ($VMHost | Get-VM | Sort Name)) { # Gather Stats $Ready = $VM | Get-Stat -Stat Cpu.Ready.Summation -RealTime $Used = $VM | Get-Stat -Stat Cpu.Used.Summation -RealTime $Wait = $VM | Get-Stat -Stat Cpu.Wait.Summation -RealTime For ($a = 0; $a -lt $VM.NumCpu; $a++) { $myObj = "" | Select VMHost, VM, Instance, %RDY, %USED, %WAIT $myObj.VMHost = $VMHost.Name $myObj.VM = $VM.Name $myObj.Instance = $a $myObj."%RDY" = [Math]::Round((($Ready | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average)/200,1) $myObj."%USED" = [Math]::Round((($Used | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average)/200,1) $myObj."%WAIT" = [Math]::Round((($Wait | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average)/200,1) $myCol += $myObj } Clear-Variable Ready -ErrorAction SilentlyContinue Clear-Variable Wait -ErrorAction SilentlyContinue Clear-Variable Used -ErrorAction SilentlyContinue Clear-Variable myObj -ErrorAction SilentlyContinue } } Disconnect-VIServer -Confirm:$false # Export and launch output $myCol | Export-Csv $OutFile Invoke-Item $OutFile |
10 Responses to Examine VMware CPU Ready Times with Powershell
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





thx! this is really powerful and useful for my environment!
-ja
[...] (By the way, here is a nice Powershell script that will grab CPU Ready stats for all of your VMs!) [...]
Thanks — I was looking at trying to write something like this myself – Now I get the credit without the work
would be nice if the script would exclude powerd off vm’s
-Sven
That’s rather easy. Simply replace this line:
ForEach ($VM in ($VMHost | Get-VM | Sort Name))
With this:
ForEach ($VM in ($VMHost | Get-VM | Where {$_.PowerState -ne “PoweredOff”} | Sort Name))
Hugo
Nice script, but when running in a 1500 VM enviroment it takes a long time for the script to finish.
[...] времени, чтобы написать эту статью Источник <http://www.peetersonline.nl/index.php/vmware/examine-vmware-cpu-ready-times-with-powershell/> wpa2a.script_load(); Categories: vmware, Виртуализация Tags: CPU Ready, PowerCLI, [...]
[...] Examine VMware CPU Ready Times with Powershell Categories: Uncategorized Tags: Comments (0) Trackbacks (0) Leave a comment Trackback [...]
Id like to see an extra column of CPU ready time in Milliseconds. AND to be able to run this over a month or year instead of using the realtime.
Answered one part myself Added
$Time = $VM | Get-Stat -Stat Cpu.Ready.Summation -RealTime
And
$myObj = “” | Select VMHost, VM, Instance, %RDY, %USED, %WAIT, %TIME
and
$myObj.”%TIME” = [Math]::Round((($Time | Where {$_.Instance -eq $a} | Measure-Object -Property Value -Average).Average))
to get time in milliseconds.
Just need to figure out how i can do this over the past month