Start a Conversation

Unsolved

This post is more than 5 years old

833

December 17th, 2011 14:00

Checking pathing for your block LUNs

Below is a script I just threw together that will give you a summary list of the current status of pathing across all of the hosts that you specify and block devices associated to those hosts.  As well it returns LUN identification information.  Nothing new here, but wanted to lay out a pretty concise block of code with the important stuff that I believe you should pay attention to if you're running block for VMware. I'm not going to specify best practices here, but this information will help you align a whole environment for consistency against BP.

The last line, ($arrOut | select name,vmhost,paths,activepaths,psp,satp) can be modified to ($arrOut | out-gridview) if you want to see a sortable chart.  The first line (Get-VMHost can be limited to only look at a cluster by (get-cluster name | get-vmhost) or a single host (get-vmhost name).

[array]$arrVMHost = Get-VMHost

[array]$arrOut = %{ $arrVMHost | %{

            $VMHost = $_

            $configStorageSystem = Get-View (Get-View $VMHost.ID).ConfigManager.StorageSystem

            [array]$arrVolumeMountInfo = $configStorageSystem.FileSystemVolumeInfo.MountInfo

            [array]$arrStorageDeviceInfo = $configStorageSystem.StorageDeviceInfo.ScsiLun

            [array]$arrMILuns = $configStorageSystem.StorageDeviceInfo.MultipathInfo.Lun

            $arrVolumeMountInfo | where {$_.volume.type -eq "VMFS"} | %{

                $VMI = $_

                $VMI.Volume.Extent | %{

                    $VolumeExtent = $_

                    $arrMILuns | where {($_.path  | select -first 1 | %{ $_.key -split "-" | select -last 1 }) -eq $VolumeExtent.DiskName } | %{ $lun = $_ }

                    $arrStorageDeviceInfo | where { $_.uuid -eq $lun.id } | select @{n="name";e={$VMI.Volume.Name}},

                                                                                   @{n="vmhost";e={$VMHost.name}},

                                                                                   @{n="lunid";e={$lun.id}},

                                                                                   @{n="lunuuid";e={$_.canonicalname}},

                                                                                   @{n="vmfsuuid";e={$VMI.Volume.Uuid}},

                                                                                   @{n="paths";e={($lun.path | where {@("active","standby") -contains $_.PathState} | measure).count}},

                                                                                   @{n="activepaths";e={($lun.path | where {$_.PathState -eq "active"} | measure).count}},

                                                                                   @{n="psp";e={($lun.policy | %{ $_.policy }) -join ","}},

                                                                                   @{n="satp";e={($lun.StorageArrayTypePolicy | %{ $_.policy }) -join ","}}

                } 

            }

        } | sort name,vmhost

    }

    $arrOut | select name,vmhost,paths,activepaths,psp,satp

2 Attachments

No Responses!
No Events found!

Top