I am trying to get the value of the metric "cpu.readiness.average" of a virtual machine in a host with version ESXi 6.0 U2 (build 4192238) and PowerCLI 6.3
I try to get the value with 2 different ways:
Get-Stat -Entity $Server -Realtime -MaxSamples 5 -Stat cpu.readiness.average
MetricId Timestamp Value Unit Instance
-------- --------- ----- ---- --------
cpu.readiness.average 25/11/2016 10:25:40 0,11 %
cpu.readiness.average 25/11/2016 10:25:20 0,12 %
cpu.readiness.average 25/11/2016 10:25:00 0,09 %
cpu.readiness.average 25/11/2016 10:24:40 0,09 %
cpu.readiness.average 25/11/2016 10:24:20 0,1 %
$PQSpec = New-Object VMware.Vim.PerfQuerySpec
$PQSpec.entity = $Server_View.MoRef
$PQSpec.Format = "normal"
$PQSpec.IntervalId = 20
$PQSpec.MaxSample = 5
$PQSpec.MetricId = @()
$PMId = New-Object VMware.Vim.PerfMetricId
$PMId.counterId = 434
$PMId.Instance = ""
$PQSpec.MetricId += $PMId
$stats = $perfMgr.QueryPerf($PQSpec)
$stats.Value.Value
9
9
12
11
12
The query return different values. 9 vs 0.09 or 11 vs 0.11
I obtain the same behaviour with other metrics with percent as unit (for example: cpu.usage.average with values of 3665 vs 36)
I understand that the right value is the value that i obtain with Get-Stat because is the same value that show the graphic in the Performance view of the vsphere web client, and i have to adjust the percent values obtain with PerformanceManager and divide by 100
Is that right?
Thanks
Since the PerformanceManager only returns 64-bit int values, it can't give decimal values.
In fact the value you get directly from the PerformanceManager must be divided by 10000 (as is the case for all metric values with unittype percent).
The scale of all the possible unittypes is documented in the PerformanceManagerUnit enumeration.
It states "Percentage values in units of 1/100th of a percent. For example 100 represents 1%."
That conversion does the Get-Stat cmdlet for you.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Since the PerformanceManager only returns 64-bit int values, it can't give decimal values.
In fact the value you get directly from the PerformanceManager must be divided by 10000 (as is the case for all metric values with unittype percent).
The scale of all the possible unittypes is documented in the PerformanceManagerUnit enumeration.
It states "Percentage values in units of 1/100th of a percent. For example 100 represents 1%."
That conversion does the Get-Stat cmdlet for you.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thats de answer i was looking for.
"Percentage values in units of 1/100th of a percent. For example 100 represents 1%"
Thanks