Friday, September 27, 2013

How to check ESXi Hosts for dead paths and validate multi-pathing or PowerPath is working correctly

The other day I was requested to assist a storage engineer with validating all of the ESXi blade HBA devices are multi-pathing as we are getting ready to perform firmware upgrades to our MDS switches and we wanted to validate there aren't any “Dead” paths that would cause a storage failure when each MDS switch was upgraded and rebooted.

We have too many hosts to check manually so I turned to Google and also fired up PowerCLI and was able to whip up the following.

Previously, I wrote a script using Powershell and PowerCLI to validate using the PowerPath management rmpowermt command (we use EMC PowerPath on our blades) but the output I was getting in the newer release of PowerPath (5.8) wasn't reporting correctly. So I needed to perform some soul searching aka googling.

The following can report on path states, and is easily adjustable as you can use various variables, filters, and sort features to tune it for your needs. The example of the script I used is below:









$VMHosts= Get-VMHost  | ? { $_.ConnectionState -eq"Connected"} | Sort-Object-PropertyName
$results= @()

foreach($VMHostin $VMHosts) {
Get-VMHostStorage-RescanAllHba-VMHost$VMHost| Out-Null
[ARRAY]$HBAs= $VMHost| Get-VMHostHba-Type"FibreChannel"

    foreach($HBAin $HBAs) {
    $pathState= $HBA| Get-ScsiLun| Get-ScsiLunPath| Group-Object-Propertystate
    $pathStateActive= $pathState| ? { $_.Name -eq"Active"}
    $pathStateDead= $pathState| ? { $_.Name -eq"Dead"}
    $pathStateStandby= $pathState| ? { $_.Name -eq"Standby"}
    $results+= "{0},{1},{2},{3},{4},{5}"-f$VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count
    }

}
ConvertFrom-Csv-Header"VMHost","HBA","Cluster","Active","Dead","Standby"-InputObject$results| Ft-AutoSize