VMware Cloud Community
NucleusVM
Enthusiast
Enthusiast

checking esxi hardware for problems using powercli

Is there a way to check all the esxi hosts on a vcenter for hardware issues?

Currently I have to go on each esxi, and click on the "hardware status" tab, to see if there are any errors.

It would be much faster if I could just run a script and output a report (html or csv) and just check that.

I currently have an esxi server with a memory issue so it's a good opportunity to test a script.

Thanks

0 Kudos
26 Replies
LucD
Leadership
Leadership

Try like this

foreach($esx in Get-VMHost){

    $hs = Get-View -Id $esx.ExtensionData.ConfigManager.HealthStatusSystem

    $hs.Runtime.SystemHealthInfo.NumericSensorInfo |

    where{$_.HealthState.Label -ne 'Green' -and $_.Name -notmatch 'Rollup'} |

    Select @{N='Host';E={$esx.Name}},Name,@{N='Health';E={$_.HealthState.Label}}

    $hs.Runtime.HardwareStatusInfo.MemoryStatusInfo |

    where{$_.Status.Label -ne 'Green'} |

    Select @{N='Host';E={$esx.Name}},Name,@{N='Health';E={$_.Status.Label}}

    $hs.Runtime.HardwareStatusInfo.CpuStatusInfo |

    where{$_.Status.Label -ne 'Green'} |

    Select @{N='Host';E={$esx.Name}},Name,@{N='Health';E={$_.Status.Label}}

    $hs.Runtime.HardwareStatusInfo.StorageStatusInfo |

    where{$_.Status.Label -ne 'Green'} |

    Select @{N='Host';E={$esx.Name}},Name,@{N='Health';E={$_.Status.Label}}

}


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

0 Kudos
NucleusVM
Enthusiast
Enthusiast

It's working now, but not on all the hosts.

Out of the 43 hosts, 13 are reporting their "Health" as "Unknown"

Any ideas as to what could be different on these hosts?

From the vSphere client I can see their health status on the "Hardware Status" just fine.

I've also run the following commands on the problematic hosts, but they are still reporting their "Health" as "Unknown"

Get-VMHostService -VMHost esxhostname | ? {($_.Key -eq "sfcbd-watchdog")} | Restart-VMHostService -Confirm:$False

(Get-View (Get-VMHost -Name esxhostname | Get-View).ConfigManager.HealthStatusSystem).RefreshHealthStatusSystem()

(Get-View (Get-VMHost -Name esxhostname | Get-View).ConfigManager.HealthStatusSystem).ResetSystemHealthInfo()

0 Kudos
LucD
Leadership
Leadership

For the ones that are returning unknown, did you check the Updated date in the vSphere client ?

Can you try doing an Update (button in the vSphere client Hardware Status page) on one of these ESXi nodes?


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

0 Kudos
NucleusVM
Enthusiast
Enthusiast

It was up to date, but I did it again anyway. Then I run the script, but again, all the health sensors are shown as Unknown.

1.jpg

2.jpg

0 Kudos
LucD
Leadership
Leadership

Does it stay with "Updating hardware data..." ?


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

0 Kudos
NucleusVM
Enthusiast
Enthusiast

No, that's why I put the second screen shot. It finished, and updated the date and time also.

0 Kudos
NucleusVM
Enthusiast
Enthusiast

1.jpg

0 Kudos