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
Understanding System auditing with auditd
Viewed 11330 times since Fri, Apr 5, 2019
How to configure an SSH proxy server with Squid
Viewed 4014 times since Sun, Dec 6, 2020
10 Linux DIG Command Examples for DNS Lookup
Viewed 11795 times since Sun, Sep 30, 2018
RHCS6: Reduce a Global Filesystem 2 (GFS2)
Viewed 3952 times since Sun, Jun 3, 2018
RHEL: Retrieve and generate a unique SCSI identifier
Viewed 3949 times since Sat, Jun 2, 2018
RHEL7 slow ssh login
Viewed 5103 times since Tue, Aug 6, 2019
How to manage Linux password expiry with the chage command
Viewed 11903 times since Tue, Sep 11, 2018
Understanding logrotate utility part 1
Viewed 2309 times since Fri, Nov 30, 2018
RHEL: Force system to prompt for password in Single User mode
Viewed 8442 times since Sat, Jun 2, 2018
Modifying the inode count for an ext2/ext3/ext4 file system
Viewed 16866 times since Fri, Sep 18, 2020