{"id":334,"date":"2016-07-19T12:42:08","date_gmt":"2016-07-19T12:42:08","guid":{"rendered":"http:\/\/vblog.hochsticher.de\/?p=334"},"modified":"2023-03-30T10:44:08","modified_gmt":"2023-03-30T08:44:08","slug":"check-paths-on-fc-hbas","status":"publish","type":"post","link":"https:\/\/vblog.hochsticher.de\/?p=334","title":{"rendered":"Check Paths on FC-HBA&#8217;s"},"content":{"rendered":"<p>Often you have to check the&nbsp;paths on your hosts.<\/p>\n<p>At least if you <a href=\"https:\/\/vblog.hochsticher.de\/?p=187\">upgrade your UCS<\/a>&nbsp;or SAN infrastructure \ud83d\ude09 Do it with PowerCLI!<\/p>\n<p><!--more--><\/p>\n<p>I spent a big amount of time last week doing research on this topic, doing these checks with PowerCLI.<\/p>\n<p>I just wanted to see (per host) which HBA has it&#8217;s paths to his storage&nbsp;(like in the vSphere Client):<\/p>\n<p><!-- index.php -->\n<div\n\tclass=\"ngg-galleryoverview ngg-ajax-pagination-none\"\n\tid=\"ngg-gallery-343-1\">\n\n    \t<div class=\"slideshowlink\">\n        <a href='https:\/\/vblog.hochsticher.de\/index.php\/nggallery\/slideshow?p=334'>[Show slideshow]<\/a>\n\t\t\n\t<\/div>\n\t\t\t<!-- Thumbnails -->\n\t\t\t\t<div id=\"ngg-image-0\" class=\"ngg-gallery-thumbnail-box\" >\n\t\t\t\t        <div class=\"ngg-gallery-thumbnail\">\n            <a href=\"https:\/\/vblog.hochsticher.de\/wp-content\/gallery\/hba-paths\/hba-paths.jpg\"\n               title=\"\"\n               data-src=\"https:\/\/vblog.hochsticher.de\/wp-content\/gallery\/hba-paths\/hba-paths.jpg\"\n               data-thumbnail=\"https:\/\/vblog.hochsticher.de\/wp-content\/gallery\/hba-paths\/thumbs\/thumbs_hba-paths.jpg\"\n               data-image-id=\"44\"\n               data-title=\"hba-paths\"\n               data-description=\"\"\n               data-image-slug=\"hba-paths\"\n               class=\"ngg-fancybox\" rel=\"343\">\n                <img\n                    title=\"hba-paths\"\n                    alt=\"hba-paths\"\n                    src=\"https:\/\/vblog.hochsticher.de\/wp-content\/gallery\/hba-paths\/thumbs\/thumbs_hba-paths.jpg\"\n                    width=\"240\"\n                    height=\"160\"\n                    style=\"max-width:100%;\"\n                \/>\n            <\/a>\n        <\/div>\n\t\t\t\t\t\t\t<\/div> \n\t\t\t\n        \n\t\t\n\t\t<!-- Pagination -->\n\t<div class='ngg-clear'><\/div>\t<\/div>\n<\/p>\n<p>There are lots of approaches for this.<\/p>\n<p><a href=\"https:\/\/jfrmilner.wordpress.com\/2011\/08\/27\/checking-for-dead-paths-on-hbas-with-powercli\/\">jfrmilner: Check for &#8220;Dead&#8221; paths on HBAs with PowerCLI<\/a><\/p>\n<p>or this&nbsp;performance optimized version&nbsp;<a href=\"http:\/\/practical-admin.com\/blog\/powercli-show-hba-path-status\/#comment-364827\">practical-admin.com:&nbsp;PowerCLI: Show HBA Path Status<\/a><\/p>\n<p>But every script I&nbsp;found was displaying incorrect path numbers. They all made the same mistake, counting the paths from datastore side. If you want to get the same result as in vSphere client, you should have a look on my script.<\/p>\n<p>So I had to find my&nbsp;way &#8230;<\/p>\n<p>At this point there goes a big thank you to &#8220;PowerCLI God&#8221;&nbsp;<a href=\"http:\/\/www.lucd.info\/\">LucD<\/a>&nbsp;\ud83d\ude09<\/p>\n<p>Finally I came up with a script that does exactly what I have imagined:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"font-size:10 line-height:12 lang:ps decode:true \">function Get-FCPaths\n{\n  &lt;#\n      .SYNOPSIS\n      It shows the HBA's with it's Paths (Active,Dead,Standby)\n      .DESCRIPTION\n      You can check a single Host, a Cluster or even a DataCenter to show it's HBA's and their paths.\n      It's tested with Cisco UCS Blades including VIC Cards and QLogic FC HBA's in Dell Hosts.\n      Check the Driver Name (and edit in Line 75) in case of trouble.\n      .EXAMPLE\n\n      Get-FCPaths -vHost myHost-01\n\n      Get-FCPaths -vHost myHost-*\n\n      Get-FCPaths -Cluster myCluster\n\n      Get-FCPaths -DataCenter myDataCenter\n\n     .EXAMPLE Output\n\n      VMHost  Device Active Standby Dead\n      ------  ------ ------ ------- ----\n      Host-01 vmhba1      0       0    4\n      Host-01 vmhba2      4       0    0\n\n   #&gt;\n  [CmdletBinding()]\n  param\n  (\n    [Parameter(Mandatory=$false, Position=0)]\n    [System.String]\n    $vHost = \"\",\n    \n    [Parameter(Mandatory=$false, Position=1)]\n    [System.String]\n    $Cluster = \"\",\n    \n    [Parameter(Mandatory=$false, Position=2)]\n    [System.String]\n    $DataCenter = \"\"\n  )\n  \n  #Check which Variable is filled\n  if([string]::IsNullOrEmpty($vHost)) {            \n    #Write-Host \"Given string is NULL or EMPTY\"\n    \n  } else {            \n    #Write-Host \"Set vobject\" \n    $vobject = (Get-VMHost $vHost)  | Sort-Object -Property Name              \n  }\n  \n  if([string]::IsNullOrEmpty($Cluster)) {            \n    #Write-Host \"Given string is NULL or EMPTY\"  \n  } else {            \n    #Write-Host \"Set vobject\" \n    $vobject = (Get-Cluster $Cluster| Get-VMHost)  | Sort-Object -Property Name            \n  }\n  \n  if([string]::IsNullOrEmpty($DataCenter)) {            \n    #Write-Host \"Given string is NULL or EMPTY\"\n    \n  } else {            \n    #Write-Host \"Set vobject\"\n    $vobject = (Get-DataCenter $DataCenter| Get-VMHost)  | Sort-Object -Property Parent,Name              \n  }\n  \n  \n  \n  foreach($vmhost in ($vobject)){\n    \n    $esx = Get-VMHost -Name $vmhost\n    $report = @()\n    # fc or fnic for UCS VIC-Cards\n    foreach($hba in ($esx.ExtensionData.Config.StorageDevice.HostBusAdapter | where{$_.Driver -match 'fc' -or  $_.Driver -match 'fnic'})){\n      $paths = @()\n      foreach($lun in $esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun){\n        $paths += $lun.Path | where{$_.Adapter -match \"$($hba.Device)\"&nbsp;-and $_.Adapter -match 'FibreChannel'}\n      }\n      $groups = $paths | Group-Object -Property PathState\n      $report += $hba | Select @{N='VMHost';E={$esx.Name}},Device,\n      @{N='Active';E={($groups | where{$_.Name -eq 'active'}).Count}},\n      @{N='Standby';E={($groups | where{$_.Name -eq 'standby'}).Count}},\n      @{N='Dead';E={($groups | where{$_.Name -eq 'dead'}).Count}}\n    }\n    Write-Host \"Cluster: \"$vmhost.Parent\n    $report | ft -AutoSize\n    \n  }\n}<\/pre>\n<hr>\n<p>The output should look like this:<\/p>\n<pre class=\"font-size:10 line-height:10 lang:ps decode:true\">PS C:\\Users\\myuser&gt; Get-FCPaths -Cluster MyCluster-0*\nCluster:  MyCluster-01\n\nVMHost  Device Active Standby Dead\n------  ------ ------ ------- ----\nHost-01 vmhba3      2       1    0\nHost-01 vmhba4      3       0    0\n\n\nCluster:  MyCluster-01\n\nVMHost  Device Active Standby Dead\n------  ------ ------ ------- ----\nHost-02 vmhba3      2       1    0\nHost-02 vmhba4      3       0    0\n\n\nCluster:  MyCluster-02\n\nVMHost  Device Active Standby Dead\n------  ------ ------ ------- ----\nHost-03 vmhba1      2       0    0\nHost-03 vmhba2      2       0    0\n\n\nCluster:  MyCluster-02\n\nVMHost  Device Active Standby Dead\n------  ------ ------ ------- ----\nHost-04 vmhba1      2       0    0\nHost-04 vmhba2      2       0    0<\/pre>\n<p><strong>UPDATE:<\/strong><\/p>\n<p>There is a cosmetic issue in ESXi 6.0 U3! See&nbsp;<a href=\"https:\/\/kb.vmware.com\/kb\/2149992\" target=\"_blank\" rel=\"noopener noreferrer\">VMware KB 2149992<\/a><\/p>\n<p><em>This causes a wrong number of active paths shown.<\/em><\/p>\n<p><strong>UPDATE2:<\/strong><\/p>\n<p>It works correctly again with ESXi 6.5 U1 \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Often you have to check the&nbsp;paths on your hosts. At least if you upgrade your UCS&nbsp;or SAN infrastructure \ud83d\ude09 Do it with PowerCLI!<\/p>\n","protected":false},"author":1,"featured_media":351,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[4,7],"tags":[],"class_list":["post-334","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powercli","category-vsphere"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts\/334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=334"}],"version-history":[{"count":19,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts\/334\/revisions"}],"predecessor-version":[{"id":1114,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/posts\/334\/revisions\/1114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=\/wp\/v2\/media\/351"}],"wp:attachment":[{"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vblog.hochsticher.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}