Script: cluster ready time
Last week I got back from holiday, had a wonderful time in France with great weather. Anyway, we're looking into changing one pool with virtual desktops from one vCPU to two vCPUs. Looking a CPU load on every host in the cluster should allow that, but we are very curious what the ready time would be.
Ready time is a VM metric, but we want to know the 'average' on the whole cluster. PowerCLI to the rescue:
$vcentername = "vcentername"
$clustername = "clustername"
$stattype = "cpu.ready.summation"
Connect-VIServer $vcentername
$cluster = Get-Cluster -name $clustername
$vms = Get-VM -Location $cluster | ?{$_.PowerState -eq "PoweredOn"}
$stats = Get-Stat -Realtime -Entity $vms -Stat $stattype
$alltotals = $stats | Measure-Object -Property Value -Minimum -Average -Maximum -Sum
$max = $alltotals.Maximum
$min = $alltotals.Minimum
$ave = [Math]::Round($alltotals.Average , 2)
$range1 = ($stats | ?{$_.Value -lt 24}).count
$range2 = ($stats | ?{$_.Value -gt 25 -and $_.Value -lt 74}).count
$range3 = ($stats | ?{$_.Value -gt 75 -and $_.Value -lt 149}).count
$range4 = ($stats | ?{$_.Value -gt 150 -and $_.Value -lt 249}).count
$range5 = ($stats | ?{$_.Value -gt 250 -and $_.Value -lt 374}).count
$range6 = ($stats | ?{$_.Value -gt 375 -and $_.Value -lt 524}).count
$range7 = ($stats | ?{$_.Value -gt 525 -and $_.Value -lt 699}).count
$range8 = ($stats | ?{$_.Value -gt 700 -and $_.Value -lt 899}).count
$range9 = ($stats | ?{$_.Value -gt 900 -and $_.Value -lt 1124}).count
$range10 = ($stats | ?{$_.Value -gt 1125 -and $_.Value -lt 1374}).count
$range11 = ($stats | ?{$_.Value -gt 1375 -and $_.Value -lt 1649}).count
$range12 = ($stats | ?{$_.Value -gt 1650 -and $_.Value -lt 1949}).count
$range13 = ($stats | ?{$_.Value -gt 1950 -and $_.Value -lt 2274}).count
$range14 = ($stats | ?{$_.Value -gt 2275}).count
Write-Host "min: $min"
Write-Host "ave: $ave"
Write-Host "max: $max"
Write-Host "24: $range1"
Write-Host "25-74: $range2"
Write-Host "75-149: $range3"
Write-Host "150-249: $range4"
Write-Host "250-374: $range5"
Write-Host "375-524: $range6"
Write-Host "525-699: $range7"
Write-Host "700-899: $range8"
Write-Host "900-1124: $range9"
Write-Host "1125-1374: $range10"
Write-Host "1375-1649: $range11"
Write-Host "1650-1949: $range12"
Write-Host "1950-2274: $range13"
Write-Host "2275>: $range14"
So here is a sample output:
min: 7
ave: 91.09
max: 1705
25-74: 37418
75-149: 27470
150-249: 9858
250-374: 4346
375-524: 1942
525-699: 756
700-899: 224
900-1124: 110
1125-1374: 14
1375-1649: 12
1650-1949: 2
1950-2274:
2275>:
Which would make a graph like this:

I'll post the results after we upgrade to 2 vCPUs to determine the impact on readytime.
Hi,
can I retrieve the value of CPU Ready in a specific hour? I woult create a script that, invoked, retrieve this value on a specific hour of the current day.
Thank you