Friday, June 5, 2015

Locating WWPNs on Linux servers

Locating WWPNs on Linux servers

I do a lot of storage-related work, and often times need to grab WWPNs to zone hosts and to mask storage. To gather the WWPNs I would often times use the following script on my RHEL and CentOS servers:
#!/bin/sh

FC_PATH="/sys/class/fc_host"
 
for fc_adapter in `ls ${FC_PATH}`
do  
    echo "${FC_PATH}/${fc_adapter}:"
    NAME=$(awk '{print $1}' ${FC_PATH}/${fc_adapter}/symbolic_name )
    echo "  $NAME `cat ${FC_PATH}/${fc_adapter}/port_name`"
done
This produced consolidated output similar to:
print_wwpns
/sys/class/fc_host/host5:
  QLE2562 0x21000024ff45afc2
/sys/class/fc_host/host6:
  QLE2562 0x21000024ff45afc3
While doing some research I came across sysfsutils, which contains the incredibly useful systool utility. This nifty little tool allows you to query sysfs values, and can be used to display all of the sysfs attributes for your FC adapters:
systool -c fc_host -v
This output is extremely useful for storage administrators, and provides everything you need in a nice consolidated form. +1 for systool!
http://prefetch.net/blog/

No comments:

Post a Comment