VMware Cloud Community
iefke
Enthusiast
Enthusiast
Jump to solution

Display active paths per datastore per host

I'm looking for a PowerCLI script that displays per cluster, per ESXi host how many active paths a datastore has.The output must look like:

Host            Datastore                Active Paths

ESXi01        VMFS-01                2

Thanks,

Ivo

Blog: http://www.ivobeerens.nl
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try this one, it show the actual count of the "active" paths per datastore.

foreach($esx in Get-VMHost){
 
$hss = Get-View $esx.Extensiondata.ConfigManager.StorageSystem

 
$lunTab = @{}
 
$hss.StorageDeviceInfo.ScsiLun | %{
   
$lunTab.Add($_.Key,$_.CanonicalName)
  }
 
$pathTab = @{}
 
$hss.StorageDeviceInfo.MultipathInfo.Lun | %{
   
$pathState = @($_.Path | Group-Object -Property PathState |
   
where {$_.Name -eq "active"} | Select -ExpandProperty Group)

   
if($pathTab.ContainsKey($_.Lun)){
     
$pathTab[$_.Lun] += $pathState.Count
    }
   
else{
     
$pathTab.Add($lunTab[$_.Lun],$pathState.Count)
    }
  }

 
foreach($mount in ($hss.FileSystemVolumeInfo.MountInfo | where {$_.Volume.Type -eq "VMFS"})){
   
$mount.Volume.Extent |
   
Select @{N="VMHost";E={$esx.Name}},
     
@{N="Datastore";E={$mount.Volume.Name}},
     
@{N="LUN";E={$_.DiskName}},
     
@{N="Active Paths";E={$pathTab[$_.DiskName]}}
  }
}


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

View solution in original post

0 Kudos
3 Replies
UmeshAhuja
Commander
Commander
Jump to solution

Hi,

Go with this.... Will help you in getting your requirement.

https://communities.vmware.com/message/1090993?tstart=0

Thanks n Regards
Umesh Ahuja

If your query resolved then please consider awarding points by correct or helpful marking.
LucD
Leadership
Leadership
Jump to solution

Try this one, it show the actual count of the "active" paths per datastore.

foreach($esx in Get-VMHost){
 
$hss = Get-View $esx.Extensiondata.ConfigManager.StorageSystem

 
$lunTab = @{}
 
$hss.StorageDeviceInfo.ScsiLun | %{
   
$lunTab.Add($_.Key,$_.CanonicalName)
  }
 
$pathTab = @{}
 
$hss.StorageDeviceInfo.MultipathInfo.Lun | %{
   
$pathState = @($_.Path | Group-Object -Property PathState |
   
where {$_.Name -eq "active"} | Select -ExpandProperty Group)

   
if($pathTab.ContainsKey($_.Lun)){
     
$pathTab[$_.Lun] += $pathState.Count
    }
   
else{
     
$pathTab.Add($lunTab[$_.Lun],$pathState.Count)
    }
  }

 
foreach($mount in ($hss.FileSystemVolumeInfo.MountInfo | where {$_.Volume.Type -eq "VMFS"})){
   
$mount.Volume.Extent |
   
Select @{N="VMHost";E={$esx.Name}},
     
@{N="Datastore";E={$mount.Volume.Name}},
     
@{N="LUN";E={$_.DiskName}},
     
@{N="Active Paths";E={$pathTab[$_.DiskName]}}
  }
}


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

0 Kudos
iefke
Enthusiast
Enthusiast
Jump to solution

Thanks for the script Luc!

Blog: http://www.ivobeerens.nl
0 Kudos