When measuring virtual machine performance data there is one important metric that is often overlooked; CPU ready time of a virtual machine. The ready time is the amount of time the virtual machine waits for processor time. This means that the virtual machine has data to process but the processing core(s) are yet to be allocated to complete the task. This amounts to milliseconds at a time, but obviously, the more virtual machines you have the worse this figure gets.
The metric returned by vCenter is called the summation. This value is not straight forward to understand and it’s also changed based on the sample interval too, so you never get the same static figure for comparison, or easy comparison at least. A more meaningful way to look at CPU ready data is as a percentage. This allows you to look at a virtual machine and know for x percent of the given sample interval (day, week, month) it was waiting for CPU cycles. VMware give a formula on their website for calculating this, which is great, but it’s far more useful to have it as a handy PowerShell function sat in my modules file. This module will accept pipeline input so it’s really useful for using with Get-VM, amongst other things. Hopefully it will help you as much as it does me.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
function Get-VmReady { <# .SYNOPSIS Gets VMware CPU ready times based on interval provided by parameter. This calculation is done from the formula from the VMware KB article. .DESCRIPTION Get-VmReady performs a calculation on the cpu.summation value provided by the VMware stats engine. .PARAMETER VmList One or more virtual machine naes or objects. .PARAMETER Interval Parameter to indicate calculation timeframe. Can be Day, Week or Month. .EXAMPLE Get-Content servernames.txt | Get-VMReady -Interval Day .EXAMPLE Get-VmReady VM1,VM2 -Interval Week .EXAMPLE Get-VM | Get-VmReady -Interval Day #> [CmdletBinding()] param( [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage="Virtual machine(s)")] [string[]]$VmList, [string]$Interval = "Day" ) BEGIN{ Switch($Interval){ "day" {$Days =- 1; $Mins = 5; $Divider = 3000} "week" {$Days =- 7; $Mins = 30; $Divider = 18000} "month" {$Days =- 30; $Mins = 120; $Divider = 72000} } } PROCESS { foreach($Vm in $VmList) { Try { $VmDetails = Get-VM -Name $Vm -ErrorAction Stop if($VmDetails.PowerState -eq "PoweredOn") { $VmHost = $VmDetails | Get-VmHost $StatGrp = $VmDetails | Get-Stat -Stat cpu.ready.summation ` -Start (Get-Date).AddDays($Days) ` -Finish (Get-Date) ` -Interval $Mins ` -Instance "" ` -ErrorAction Stop | Group Entity foreach($Stat in $StatGrp) { $ReadyTimes = @{ 'VM Name' = $Vm; 'Ready %' = “{0:n2}” -f (($Stat.group | Measure-Object Value -ave).average / $Divider); 'Num CPUs' = $VmDetails.NumCpu; 'Host' = $VmHost.Name } } $ReadyObj = New-Object -TypeName PSObject -Property $ReadyTimes $ReadyObj.PSObject.TypeNames.Insert(0,'DzVmToolsPS.Get-VmReady'); Write-Output $ReadyObj } } Catch { Write-Warning "Virtual Machine $Vm not found!" } } } } |
Leave a Reply