banerian
VMware Employee
VMware Employee

HBAs with no LUNs or targets

Does anyone have a script laying around that will interogate a host and report any HBAs which have no LUNs/targets associated them them?

Thanks in advance.

0 Kudos
6 Replies
conyards
Expert
Expert

esxcfg-mpath -b  when run from the service console will give you this information.

https://virtual-simon.co.uk/
0 Kudos
banerian
VMware Employee
VMware Employee

Thanks, but this shows which HBAs DO have targets.  I'm looking for a scriptable way to report which HBAs do NOT have targets.

0 Kudos
LucD
Leadership
Leadership

Try this

Get-VMHostHba -VMHost (Get-VMHost -Name $esxName) | where {!$_.ScsiLunUids} | Select Name


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

0 Kudos
banerian
VMware Employee
VMware Employee

No LucD, I'm afraid that doesn't work for me.

I get all 4 HBAs returned like this:

Device   : vmhba32
Key      : key-vim.host.BlockHba-vmhba32
Model    : ICH10 4 port SATA IDE Controller
Pci      : 00:1f.2
Driver   : ata_piix
Bus      : 0
VMHostId : HostSystem-host-83
Status   : Unknown
Type     : Block

So, $_.ScsiLunUids doesn't exits, and neither does Name for that matter.  This is the tricky part - I simply can not figure out how to relate get-vmhosthba's ouput to the targets/luns.  In VC, when you select an adapter you immediately are presented with the number of Targets, Devices, and Paths, - how can that be done in pcli?

0 Kudos
RvdNieuwendijk
Leadership
Leadership

It looks like you don't have the latest PowerCLI version 4.1U1 as you don't have the ExtensionData property. You can check your PowerCLI version with the Get-PowerCLIVersion cmdlet.

You can get the number of Targets, Devices, and Paths with the following PowerCLI script:

Get-VMHost | Sort-Object -property Name | ForEach-Object {
  $VMHost = $_
  $VMHost | Get-VMHostHba | Sort-Object -property Device | ForEach-Object {
    $VMHostHba = $_
    $ScsiLun = $VMHostHba | Get-ScsiLun
    If ($ScsiLun) {
      $ScsiLunPath = $ScsiLun | Get-ScsiLunPath | `
        Where-Object {$_.Name -like "$($VMHostHba.Device)*"}
      $Targets = ($ScsiLunPath | `
        Group-Object -Property SanID | Measure-Object).Count
      $Devices = ($ScsiLun | Measure-Object).Count
      $Paths = ($ScsiLunPath | Measure-Object).Count
    }
    Else {
      $Targets = 0
      $Devices = 0
      $Paths = 0
    }
    $Report = "" | Select-Object -Property VMHost,HBA,Targets,Devices,Paths
    $Report.VMHost = $VMHost.Name
    $Report.HBA = $VMHostHba.Device
    $Report.Targets = $Targets
    $Report.Devices = $Devices
    $Report.Paths = $Paths
    $Report
  }
}

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
banerian
VMware Employee
VMware Employee

It's probably true that I'm on an older version.  I will check.  Right now $ScsiLun = $VMHostHba | Get-ScsiLun is throwing an error - it doesn't like the pipeline.  Let me check/update and see.  Thanks for the example!!

0 Kudos