I'm trying to read the temperature values available on the hardware status tab on our hosts via PowerCLI:
Get-VMHost | Sort | % {
$reading = ((Get-View $_.id).Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ? {$_.Name -like "*External Environment*"}).CurrentReading
Write "$_`t$reading"
}
host1 2100
host2 2300
[...]
The values are usually off by a few degrees if I compare them to the values displayed on the ILO website of the host or the hardware status tab in the vSphere Client (which are matching up).
I tried refreshing sensors manually in the Client and executing:
(Get-View (Get-VMHost -Name host1 | Get-View).ConfigManager.HealthStatusSystem).ResetSystemHealthInfo()
(Get-View (Get-VMHost -Name host1 | Get-View).ConfigManager.HealthStatusSystem).UpdateViewData()
(Get-View (Get-VMHost -Name host1 | Get-View).ConfigManager.HealthStatusSystem).RefreshHealthStatusSystem()
as suggested by http://kb.vmware.com/kb/1037330, but I still get old (or incorrect?) values when querying the temperature like above through PowerCLI
Using ESXi 5.0 U1 and PowerCLI 5.0.1 build 581491.
Did you try calling UpdateViewData after RefreshHealthStatusSystem ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, I tried executing them in various sequences, no change though.
These are HP Proliant 380 G5/G6 Servers with the almost latest HP CIM providers from September (hp-smx-provider 500.03.01.00.5-434156). The PowerCLI values for all temperature sensors are usually off by up to 5 degrees celsius:
Get-VMHost | Sort | % {
((Get-View $_.id).Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ? {$_.SensorType -like "*temperature*"}) | Select Name, CurrentReading | ft -autosize
}
Btw how do I use the cool Powershell syntax highlighting in posts here?
The correctness and timeliness of the sensor data vSphere gets, depends a lot on how the HW vendor implemented these routines.
It's a bit similar to obtaining the Tag or BIOSVersion of the HW.
With some HW vendors this works ok, with others the data is not present or inaccurate.
To get correct sensor data for HP HW I would suggest also looking at the iLO interface (you can access that via PowerShell).
For the fancy code display see Some ways to enter PowerCLI code under the new forum SW
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, the main reason for my confusion is why the values displayed in the vSphere Client and the ones retrieved via PowerCLI don't match up though. I assume(d) they would be based on the same underlying API calls or data records.
This made me wonder enough to run this against a host directly and not against vCenter. And sure enough, this brought up different, "closer" results and after a RefreshHealthStatusSystem() and UpdateViewData() I now get the exact values for all sensors.
Now I'd just love to access these correct and current numbers centrally through vCenter.
That seems to indicate it's a vCenter caching thing ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sure does look like a caching issue. The Refresh, Update and actual query also complete noticably faster through vCenter.
ESXi hostd.log and vpxa.log when running RefreshHealthStatusSystem() through vCenter:
(Get-View (Get-VMHost -Name host1 | Get-View).ConfigManager.HealthStatusSystem).RefreshHealthStatusSystem()
2012-11-20T15:11:15.622+01:00 Hostd [39D8AB90 info 'TaskManager' opID=3e4343d9-df] Task Created : haTask-ha-host-vim.host.HealthStatusSystem.refresh-110553556
2012-11-20T15:11:15.623+01:00 Hostd [39D8AB90 info 'TaskManager' opID=3e4343d9-df] Task Completed : haTask-ha-host-vim.host.HealthStatusSystem.refresh-110553556 Status success
2012-11-20T15:11:15.624+01:00 Hostd [39E0FB90 verbose 'Cimsvc' opID=3e4343d9-df] Ticket issued for CIMOM version 1.0, user root
2012-11-20T15:19:24.285+01:00 Vpxa [390EBB90 info 'Default' opID=4f10e218-1e] [VpxLRO] -- BEGIN task-internal-389 -- -- vim.host.HealthStatusSystem.refresh -- 5208fd2e-1207-0253-60e8-f580692d8cbf
2012-11-20T15:19:24.287+01:00 Vpxa [390EBB90 info 'Default' opID=4f10e218-1e] [VpxLRO] -- FINISH task-internal-389 -- -- vim.host.HealthStatusSystem.refresh -- 5208fd2e-1207-0253-60e8-f580692d8cbf
However, nothing is logged in the ESXi vpxa or hostd log when executing UpdateViewData() or the actual data query through vCenter.
Running UpdateViewData() or the query against the ESXi host directly works and produces loads of messages like this in the hostd.log:
2012-11-20T15:16:23.882+01:00 Hostd [392FDB90 verbose 'Locale'] Default resource used for 'host.SystemIdentificationInfo.IdentifierType.AssetTag.summary' expected in module 'enum'.
2012-11-20T15:16:23.882+01:00 Hostd [392FDB90 verbose 'Locale'] Default resource used for 'host.SystemIdentificationInfo.IdentifierType.OemSpecificString.label' expected in module 'enum'.
2012-11-20T15:16:23.883+01:00 Hostd [392FDB90 verbose 'Locale'] Default resource used for 'host.SystemIdentificationInfo.IdentifierType.OemSpecificString.summary' expected in module 'enum'.
I think the UpdateViewData method is a PowerCLI .Net method that asks PowerCLI to refresh the content of the object.
But you would expect it to generate a refresh call , even when connected to a vCenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I ran into a similar problem (in PowerCLI 5.0) with stale data being returned from the Get-VMHostAdvancedConfiguration -name Annotations.WelcomeMessage call, original post is listed below.
The data was only refreshed when I rebooted the server, which was good enough for me, because I always reboot the server in my particular situation. However, it is not an ideal situation.
I agree though, I would like to see a refresh call, too.
http://communities.vmware.com/thread/435494?start=0&tstart=0