VMware Cloud Community
kbr5678
Contributor
Contributor

Vsphere Host Health status - VI SDK

Hi..

In our envirounment previously we used vCenter 2.5 ..We are getting the health status via HostSystem->runtimeinfo->systemHealthInfo.Now we are using vSphere vCenter using the same path..reading are not updated in new vSphere vCenter..But old vCenter 2.5 readings are changed..

And also If i connect host directly readings are changed.Problem is if I connect vSphere vCenter the reading are not changed..Any idea about that problem.Or any other way to collect vSphere vCenter host health status..

0 Kudos
2 Replies
LucD
Leadership
Leadership

If you look at the HostHealthStatusSystem object you will notice that since vSphere there are now 2 methods on the object.

To get refreshed data for the sensors, you will have to call the RefreshHealthStatusSystem method.

Same as you have to do in the Hardware Status tab in the vSphere client. There you to click to refresh the sensor data.

In a script you could do this like this

$esx = Get-VMHost <ESX-name> | Get-View
# Get the current sensor data
$health1 = $esx.Runtime.HealthSystemRuntime.SystemHealthInfo

# Wait for example 5 minutes
sleep 300

# Call the refresh
$healthMgr = Get-View $esx.ConfigManager.HealthStatusSystem
$healthMgr.RefreshHealthStatusSystem()

# Get the current sensor data
$health2 = $esx.Runtime.HealthSystemRuntime.SystemHealthInfo

# Compare the sensor data from the 2 measurements
for($i = 0; $i -lt $health1.NumericSensorInfo.counCount; $i++){
	if($health1.NumericSensorInfo[$i].CurrentReading -ne $health2.NumericSensorInfo[$i].CurrentReading){
		Write-Host $health1.NumericSensorInfo[$i].Name $health1.NumericSensorInfo[$i].CurrentReading $health2.NumericSensorInfo[$i].CurrentReading
	}
}


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

0 Kudos
kbr5678
Contributor
Contributor

Hi..

Thanks a lot.Its working fine

0 Kudos