Linux get the list of FC HBA’s and WWPN

This simple script gives you the list of FC HBA detected in system. It query the sysfs filesystem to get the available fibre channel HBA. Script works for most of the Linux flavors, as specially any of Redhat, SUSE, Fedora and Centos distributions.

This script will not alter any of system configuration rather it just query the sysfs filesystem. Copy the script to server and execute it. Output collected under file “/tmp/hba_list.txt”.

Note

This script will not list the HBA if there is any hardware or driver issue. In such case refer “dmesg“ to troubleshoot further.

 

#!/bin/bash
#
# Display available FC Ports and their WWPN
echo "--------------------------------------------------"
echo -e "\tCollecting the available HBA details. \n\tOutput stored as /tmp/hba_list.txt"
echo "--------------------------------------------------"

for hba in `ls -d /sys/class/fc_host/host*`;do
FC_HOST=`basename $hba`
PortID=`cat $hba/port_id`
wwpn=`cat $hba/port_name`
state=`cat $hba/port_state`
speed=`cat $hba/speed`
hba=`cat $hba/symbolic_name`
cat << EOB >> /tmp/hba_list.txt

FC-Host: $FC_HOST
---------------------------------------------------------------------------
HBA WWPN : $wwpn PortId: $PortID
HBA State: $state Speed : $speed
EOB
done

Here is the sample of HBA details which has been collected by above script.

#cat /tmp/hba_list.txt

FC-Host: host1
---------------------------------------------------------------------------
HBA WWPN : 0x5001439994c99988 PortId: 0x100300
HBA State: Online Speed : 4 Gbit

FC-Host: host2
---------------------------------------------------------------------------
HBA WWPN : 0x5001439994c9998a PortId: 0x0f0300
HBA State: Online Speed : 4 Gbit
Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to configure an SSH proxy server with Squid
Viewed 3278 times since Sun, Dec 6, 2020
Setting up encrypted tunnel using stunnel
Viewed 2660 times since Fri, Sep 28, 2018
LVM: Move allocated PE between Physical Volumes
Viewed 4070 times since Sat, Jun 2, 2018
LVM: Extend SWAP size by adding a new Logical Volume
Viewed 3291 times since Sat, Jun 2, 2018
How to use yum-cron to automatically update RHEL/CentOS Linux 6.x / 7.x
Viewed 5238 times since Tue, Dec 4, 2018
Linux - How to get network speed and statistic of ethernet adapter in Linux
Viewed 2308 times since Fri, Jun 8, 2018
List of 10 Must Know Oracle Database Parameters for Database Administrator
Viewed 130188 times since Thu, Jun 21, 2018
How To: Create Self-Signed Certificate – OpenSSL
Viewed 3157 times since Mon, Feb 18, 2019
RHCS6: Show/Add GFS2/GFS journals
Viewed 12874 times since Sun, Jun 3, 2018
Linux – delete the LUN and remove traces from OS
Viewed 3792 times since Tue, May 22, 2018