VMware Cloud Community
Pilu1978
Enthusiast
Enthusiast

CPU Ready Value

Hi,

I want to have a powercli script to capture the avg CPU ready value of my VMs for last 30 days in percentage.

Please help.

0 Kudos
4 Replies
LucD
Leadership
Leadership

Try something like this

$vms = Get-VM 
$start = (Get-Date).AddDays(-30 $metric = "cpu.ready.summation"
Get-Stat
-Entity $vms -Stat $metric -Start $start | Group-Object -Property {$_.Entity.Name} | %{   New-Object PSObject -Property @{     VM = $_.Values[0]     ReadyAvg = [math]::Round(($_.Group | Measure-Object -Property Value -Average | Select -ExpandProperty Average),2)   } }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
abirhasan
Enthusiast
Enthusiast

0 Kudos
Pilu1978
Enthusiast
Enthusiast

Hi LucD,

Thanks a lot for this.

But when I am running the above script for a particular VM, the ready value is showing as 4466.51. Is it in miliseconds? How to get the percentage of this value.

0 Kudos
LucD
Leadership
Leadership

The metric returns, in milliseconds, the amount of time during the interval when the CPU was in a ready state.

To get a percentage, you'll need a small calculation.

$vms = Get-VM 
$start = (Get-Date).AddDays(-30) $metric = "cpu.ready.summation" Get-Stat -Entity $vms -Stat $metric -Start $start | Group-Object -Property {$_.Entity.Name} | %{   New-Object PSObject -Property @{     VM = $_.Values[0]     ReadyAvg = &{       $interval = $_.Group[0].IntervalSecs * 1000
     
$value = $_.Group | Measure-Object -Property Value -Average | Select -ExpandProperty Average
      "{0:p}" -f ($value/$interval)     }   } }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos