POWERCLI : ESXi MultipathPolicy Check


 

 

Charger les modules VMware :

Import-Module VMware.VimAutomation.Core -WarningAction SilentlyContinue
Import-Module VMware.VimAutomation.Vds -WarningAction SilentlyContinue
Import-Module VMware.VimAutomation.License -WarningAction SilentlyContinue
Import-Module VMware.VimAutomation.Storage -WarningAction SilentlyContinue
Import-Module VMware.VimAutomation.HA -WarningAction SilentlyContinue

Se connecter au vCenter Server :

Connect-VIServer vcenter1.domain.local -WarningAction SilentlyContinue

Lister les différents volumes (LUNs), la taille et la stratégie Multipath :

Get-Vmhost esx1.domain.local | Get-Scsilun -LunType disk | Select CanonicalName, CapacityGB, MultipathPolicy
CanonicalName                        CapacityGB MultipathPolicy
-------------                        ---------- ---------------
naa.6000144000000010703cd2e2c33b11x3 6144            RoundRobin
naa.6000144000000010703cd2e2c33b8634 1024            RoundRobin
naa.6000144000000010703cd2e2c33b86rs 4096            RoundRobin
naa.6000144000000010703cd2e2c33b89a8 4096            RoundRobin
naa.6000144000000010703cd2e2c33b8b5d 8192            RoundRobin

Lister les différents volumes (LUNs) qui ne sont pas en mode MultipathPolicy RoundRobin :

Get-VMHost esx1.domain.local | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"}

Lister les différents volumes (LUNs) qui sont en mode MultipathPolicy RoundRobin :

Get-VMHost esx1.domain.local | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -like "RoundRobin"}

Changer la stratégie Multipath en mode RoundRobin pour un ESXi :

Get-Vmhost esx1.domain.local | Get-Scsilun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Where {$_.CapacityGB -ge 200} | Set-Scsilun -MultiPathPolicy RoundRobin

Changer la stratégie Multipath en mode RoundRobin pour tous les ESXi :

Get-Vmhost | Get-Scsilun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Where {$_.CapacityGB -ge 200} | Set-Scsilun -MultiPathPolicy RoundRobin

Lister les différents volumes (LUNs) et vérifier le modèle et le type de matériel :

Get-VMHost esx1.domain.local | Get-ScsiLun -LunType disk | fl -show CanonicalName, Vendor, CapacityMB, Model, LunType

Avoir la correspondance entre les CanonicalName et le nom de la LUN :

Get-Datastore |
Where-Object {$_.ExtensionData.Info.GetType().Name -eq "VmfsDatastoreInfo"} |
ForEach-Object {
  if ($_)
  {
    $Datastore = $_
    $Datastore.ExtensionData.Info.Vmfs.Extent |
    Select-Object -Property @{Name="Name";Expression={$Datastore.Name}},
      DiskName
  }
}
Name                               DiskName                            
----                               --------                            
UNITY-DATASTORE-PRD-01             naa.6006016052d044002b47c159847740f1
UNITY-DATASTORE-PRD-02             naa.6000144000000010703cd2e2c33b7cf8
UNITY-DATASTORE-PRD-03             naa.6000144000000010703cd2e2c33b8b94

Afficher les cartes HBA FC sur les hôtes ESXi ainsi que le status :

get-VMHost esx1.domain.local | Get-VMHostHba -Type "FibreChannel"
Device     Type         Model                          Status 
------     ----         -----                          ------ 
vmhba2     FibreChannel ISP2532-based 8Gb Fibre Cha... online 
vmhba3     FibreChannel ISP2532-based 8Gb Fibre Cha... unknown
vmhba4     FibreChannel ISP2532-based 8Gb Fibre Cha... online 
vmhba5     FibreChannel ISP2532-based 8Gb Fibre Cha... unknown

Afficher l’état des chemins sur les HBA (Active / Dead / Standby) :

$VMHosts = Get-VMHost esx1.domain.local  | ? { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name
$results= @()
 
foreach ($VMHost in $VMHosts) {
Get-VMHostStorage -RescanAllHba -VMHost $VMHost | Out-Null
[ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel"
 
    foreach ($HBA in $HBAs) {
    $pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state
    $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
VMHost          HBA    Cluster Active Dead Standby
------          ---    ------- ------ ---- -------
esx1            vmhba2 CluDB   72     0    0      
esx1            vmhba3 CluDB   0      0    0      
esx1            vmhba4 CluDB   72     0    0      
esx1            vmhba5 CluDB   0      0    0      

 

Print Friendly, PDF & Email

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *