msgbartop
Tips and Tricks site for advanced HP-UX Engineers
msgbarbottom

28 Oct 15 Keeping track of san disks

HP-UX does not make it easy to keep track of SAN presented disks. HBA switch ports are in short supply in many data centers. It is important for performance and reliability to be able to account for how many disks are presented to what HBA WWN ports.

This articles outlines a generic method of doing so. It is better than fcmsutil output but is based only on tools provided with the OS (with 1 small exception).

To make sharing easier, I will provide links to scripts. It is up to you to perform due diligence. The scripts write no data and do not change your system. They are provided without warranty under US Law by ISN Corporation.

I recommend against cutting and pasting scripts from this web page, errors are introduced. They are based on korn shell and do not work with bash shell. They probably work on POSIX shell but were not tested. They are specific to HP-UX B.11.31 but can if you wish be adapted to older versions of the OS.

Links to scripts are at the bottom of the post which is quite long.

Script names accurately describe their functionality
fcdisplaydev.ksh us a utility script designed to provide fcmsutil output to the other two scripts.

myserv1:root > cat pathcount_byhbaport.ksh
#!/bin/ksh
#
# Disk inventory by wwn
#
# 11.31 agile only
#
# Whole system version

## build an arry to hold wwn info
#
ap=0
zerod=0
idevice=$1

ls /dev/fc*| while read -r dv
do
/opt/fcms/bin/fcmsutil $dv | awk ‘/N_Port Port World Wide Name/{ print $(NF) }’ | while read -r wwpn
do
### echo ” array count ${ap} ..”
wwnarray[${ap}]=${wwpn}
wwncount[${ap}]=${zerod}
(( ap = ap + 1 ))
done
done
##echo ${#wwnarray[*]}
##echo ${#wwncount[*]}

calc_path()
{
### function to click counter of disks to port wwn
## set -x
## echo “calc_path $1 >>>”
fwwn=$1
fp=0
while [ ${fp} -le ${ap} ]
do
wwnport=${wwnarray[$fp]}
wwnportc=${wwncount[$fp]}
if [ “${fwwn}” = “${wwnport}” ]
then
##echo “updating wwn count ${fwwn} ..”
(( wwnportc = wwnportc + 1 ))
wwncount[${fp}]=${wwnportc}
fi
(( fp = fp + 1 ))
done
##set +x
}

if [ ! -z “$idevice” ]
then
dv=”/dev/rdisk/${idevice}”
scsimgr -p lun_map -D ${dv} | awk -F: ‘{ print $3 }’ | awk -F. ‘{ print $1 }’ | while read -r hp
do
##/var/adm/bin/fcdisplaydev.ksh ${hp}
wwnfound=$(/var/adm/bin/fcdisplaydev.ksh ${hp});
calc_path ${wwnfound}
done
else
ioscan -NfnCdisk | grep rdisk | grep -v p | awk ‘{ print $(NF) }’ | while read -r dv
do
### echo “cheking hba path disk … ${dv} ”
### scsimgr -p lun_map -D ${dv}
### scsimgr -p lun_map -D ${dv} | awk -F. ‘{ print $2 }’
scsimgr -p lun_map -D ${dv} | awk -F: ‘{ print $3 }’ | awk -F. ‘{ print $1 }’ | while read -r hp
do
##/var/adm/bin/fcdisplaydev.ksh ${hp}
wwnfound=$(/var/adm/bin/fcdisplaydev.ksh ${hp});
calc_path ${wwnfound}
done

done
fi
fp=0
echo “===========================================”
echo “= World wide port name: count ”
if [ ! -z “$idevice” ]
then
echo “= Individual device /dev/rdisk/${idevice} ”
fi
echo “===========================================”
while [ ${fp} -lt ${ap} ]
do
dv1=${wwnarray[$fp]}
dv2=${wwncount[$fp]}
echo “| ${dv1} : ${dv2} |”

(( fp = fp + 1 ))
done
echo “===========================================”

myserv1:root > cat fcdisplaydev.ksh
#!/bin/ksh
hwp=$1
ls /dev/fc*| while read -r dv
do
foundfc=$(/opt/fcms/bin/fcmsutil $dv | awk ‘/Hardware Path is/{ print $(NF) }’ | grep ${hwp} |wc -l);
if [ ${foundfc} -eq 1 ]
then
# echo “$dv to be checked.”
/opt/fcms/bin/fcmsutil $dv |awk ‘/N_Port Port World Wide Name/{ print $(NF)}’
fi
done

cat pathforalldisks.ksh
#!/bin/ksh

xpinfo -i > /tmp/xpinfo.txt

ioscan -NfnCdisk|grep rdisk | awk ‘{ print $NF }’ | grep -v _p | awk -F\/ ‘{ print $NF}’ | while read -r dsk
do
/var/adm/bin/pathcount_byhbaport.ksh $dsk
ldev=$(grep “${dsk} ” /tmp/xpinfo.txt | awk ‘{ print $6 }’ );
echo “LDEV: ${ldev}”

done

Script output. Modified to protect the security of the test systems.

fcmsutil

fcmsutil /dev/fcd0

Vendor ID is = 0x1077
Device ID is = 0x2422
PCI Sub-system Vendor ID is = 0x103C
PCI Sub-system ID is = 0x12DF
PCI Mode = PCI-X 133 MHz
ISP Code version = 5.6.5
ISP Chip version = 3
Topology = PTTOPT_FABRIC
Link Speed = 4Gb
Local N_Port_id is = 0x018100
Previous N_Port_id is = None
N_Port Node World Wide Name = 0x500143800117ef3d
N_Port Port World Wide Name = 0x500143800117ef3c
Switch Port World Wide Name = 0x20810027f8a27cd4
Switch Node World Wide Name = 0x10000027f8a27cd4
N_Port Symbolic Port Name = myserv0_fcd0
N_Port Symbolic Node Name = myserv0_HP-UX_B.11.31
Driver state = ONLINE
Hardware Path is = 0/2/1/0/4/0
Maximum Frame Size = 2048
Driver-Firmware Dump Available = NO
Driver-Firmware Dump Timestamp = N/A
TYPE = PFC
NPIV Supported = YES
Driver Version = @(#) fcd B.11.31.1403 Dec 4 2013

There is a slight error, if you have a fix please share
./pathcount_byhbaport.ksh
calc_path[14]: wwnportc = wwnportc + 1 : bad number
===========================================
= World wide port name: count
===========================================
| 0x500143800117ef3c : 24 |
| 0x500143800117ef3e : 0 |
| 0x500143800117ef40 : 24 |
| 0x500143800117ef42 : 0 |
===========================================

LDEV info is specific ti Hitachi VSP xpinfo utility. You will have to adapt that code to other storage providers.

./pathforalldisks.ksh
calc_path[14]: wwnportc = wwnportc + 1 : bad number
===========================================
= World wide port name: count
= Individual device /dev/rdisk/disk172
===========================================
| 0x500143800117ef3c : 1 |
| 0x500143800117ef3e : 0 |
| 0x500143800117ef40 : 1 |
| 0x500143800117ef42 : 0 |
===========================================
LDEV: 03:f3

Link to http://www.hpux.ws/scripts/pathcount_byhbaport.ksh

Link to http://www.hpux.ws/scripts/pathforalldisks.ksh

Link to fcdisplaydev.ksh

All scripts are provided with no warranty. Use them at your own risk.

Tags: , , ,

Leave a Comment

You must be logged in to post a comment.

sidebarbottom
sidebartop
sidebarbottom
WhatsApp chat