{"id":399,"date":"2015-10-28T12:24:53","date_gmt":"2015-10-28T17:24:53","guid":{"rendered":"http:\/\/www.hpux.ws\/?p=399"},"modified":"2015-10-28T12:28:10","modified_gmt":"2015-10-28T17:28:10","slug":"keeping-track-of-san-disks","status":"publish","type":"post","link":"https:\/\/www.hpux.ws\/?p=399","title":{"rendered":"Keeping track of san disks"},"content":{"rendered":"<p>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.<\/p>\n<p>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).<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>Links to scripts are at the bottom of the post which is quite long.<\/p>\n<p>Script names accurately describe their functionality<br \/>\nfcdisplaydev.ksh us a utility script designed to provide fcmsutil output to the other two scripts.<\/p>\n<p>myserv1:root > cat pathcount_byhbaport.ksh<br \/>\n#!\/bin\/ksh<br \/>\n#<br \/>\n# Disk inventory by wwn<br \/>\n#<br \/>\n# 11.31 agile only<br \/>\n#<br \/>\n# Whole system version<\/p>\n<p>## build an arry to hold wwn info<br \/>\n#<br \/>\nap=0<br \/>\nzerod=0<br \/>\nidevice=$1<\/p>\n<p>ls \/dev\/fc*| while read -r dv<br \/>\ndo<br \/>\n  \/opt\/fcms\/bin\/fcmsutil  $dv | awk &#8216;\/N_Port Port World Wide Name\/{ print $(NF) }&#8217; | while read -r wwpn<br \/>\n   do<br \/>\n     ###     echo &#8221; array count ${ap} ..&#8221;<br \/>\n     wwnarray[${ap}]=${wwpn}<br \/>\n     wwncount[${ap}]=${zerod}<br \/>\n     (( ap = ap + 1 ))<br \/>\n   done<br \/>\ndone<br \/>\n##echo ${#wwnarray[*]}<br \/>\n##echo ${#wwncount[*]}<\/p>\n<p>calc_path()<br \/>\n{<br \/>\n### function to click counter of disks to port wwn<br \/>\n  ##  set -x<br \/>\n##  echo &#8220;calc_path $1 >>>&#8221;<br \/>\n  fwwn=$1<br \/>\n  fp=0<br \/>\n  while [ ${fp} -le ${ap} ]<br \/>\n  do<br \/>\n  wwnport=${wwnarray[$fp]}<br \/>\n  wwnportc=${wwncount[$fp]}<br \/>\n  if [ &#8220;${fwwn}&#8221; = &#8220;${wwnport}&#8221; ]<br \/>\n  then<br \/>\n    ##echo &#8220;updating wwn count ${fwwn} ..&#8221;<br \/>\n    (( wwnportc = wwnportc + 1 ))<br \/>\n     wwncount[${fp}]=${wwnportc}<br \/>\n  fi<br \/>\n  (( fp = fp + 1 ))<br \/>\n  done<br \/>\n  ##set +x<br \/>\n}<\/p>\n<p>if [ ! -z &#8220;$idevice&#8221; ]<br \/>\nthen<br \/>\n  dv=&#8221;\/dev\/rdisk\/${idevice}&#8221;<br \/>\n   scsimgr -p lun_map -D ${dv} | awk -F: &#8216;{ print $3 }&#8217; | awk -F. &#8216;{ print $1 }&#8217; | while read -r hp<br \/>\n   do<br \/>\n     ##\/var\/adm\/bin\/fcdisplaydev.ksh ${hp}<br \/>\n     wwnfound=$(\/var\/adm\/bin\/<strong>fcdisplaydev.ksh<\/strong> ${hp});<br \/>\n     calc_path ${wwnfound}<br \/>\n   done<br \/>\nelse<br \/>\nioscan -NfnCdisk | grep rdisk | grep -v p | awk &#8216;{ print $(NF) }&#8217; | while read -r dv<br \/>\ndo<br \/>\n   ### echo &#8220;cheking hba path disk &#8230; ${dv} &#8221;<br \/>\n   ###   scsimgr -p lun_map -D ${dv}<br \/>\n   ### scsimgr -p lun_map -D ${dv} | awk -F. &#8216;{ print $2 }&#8217;<br \/>\n   scsimgr -p lun_map -D ${dv} | awk -F: &#8216;{ print $3 }&#8217; | awk -F. &#8216;{ print $1 }&#8217; | while read -r hp<br \/>\n   do<br \/>\n     ##\/var\/adm\/bin\/fcdisplaydev.ksh ${hp}<br \/>\n     wwnfound=$(\/var\/adm\/bin\/fcdisplaydev.ksh ${hp});<br \/>\n     calc_path ${wwnfound}<br \/>\n   done<\/p>\n<p>done<br \/>\nfi<br \/>\nfp=0<br \/>\necho &#8220;===========================================&#8221;<br \/>\necho &#8220;= World wide port name: count              &#8221;<br \/>\nif [ ! -z &#8220;$idevice&#8221; ]<br \/>\nthen<br \/>\n  echo &#8220;= Individual device \/dev\/rdisk\/${idevice} &#8221;<br \/>\nfi<br \/>\necho &#8220;===========================================&#8221;<br \/>\nwhile [ ${fp} -lt ${ap} ]<br \/>\ndo<br \/>\n  dv1=${wwnarray[$fp]}<br \/>\n  dv2=${wwncount[$fp]}<br \/>\n  echo &#8220;| ${dv1} : ${dv2}    |&#8221;<\/p>\n<p>  (( fp = fp + 1 ))<br \/>\ndone<br \/>\necho &#8220;===========================================&#8221;<\/p>\n<p>myserv1:root > cat fcdisplaydev.ksh<br \/>\n#!\/bin\/ksh<br \/>\nhwp=$1<br \/>\nls \/dev\/fc*| while read -r dv<br \/>\ndo<br \/>\n foundfc=$(\/opt\/fcms\/bin\/fcmsutil  $dv | awk &#8216;\/Hardware Path is\/{ print $(NF) }&#8217; | grep ${hwp} |wc -l);<br \/>\n if [ ${foundfc} -eq 1 ]<br \/>\n then<br \/>\n#    echo &#8220;$dv to be checked.&#8221;<br \/>\n    \/opt\/fcms\/bin\/fcmsutil  $dv |awk &#8216;\/N_Port Port World Wide Name\/{ print $(NF)}&#8217;<br \/>\n fi<br \/>\ndone<\/p>\n<p>cat pathforalldisks.ksh<br \/>\n#!\/bin\/ksh<\/p>\n<p>xpinfo -i > \/tmp\/xpinfo.txt<\/p>\n<p>ioscan -NfnCdisk|grep rdisk | awk &#8216;{ print $NF }&#8217; | grep -v _p | awk -F\\\/ &#8216;{ print $NF}&#8217; | while read -r dsk<br \/>\ndo<br \/>\n   \/var\/adm\/bin\/pathcount_byhbaport.ksh $dsk<br \/>\n   ldev=$(grep &#8220;${dsk} &#8221; \/tmp\/xpinfo.txt | awk &#8216;{ print $6 }&#8217; );<br \/>\n   echo &#8220;LDEV: ${ldev}&#8221;<\/p>\n<p>done<\/p>\n<p>Script output. Modified to protect the security of the test systems.<\/p>\n<p>fcmsutil<\/p>\n<p>fcmsutil \/dev\/fcd0<\/p>\n<p>                           Vendor ID is = 0x1077<br \/>\n                           Device ID is = 0x2422<br \/>\n            PCI Sub-system Vendor ID is = 0x103C<br \/>\n                   PCI Sub-system ID is = 0x12DF<br \/>\n                               PCI Mode = PCI-X 133 MHz<br \/>\n                       ISP Code version = 5.6.5<br \/>\n                       ISP Chip version = 3<br \/>\n                               Topology = PTTOPT_FABRIC<br \/>\n                             Link Speed = 4Gb<br \/>\n                     Local N_Port_id is = 0x018100<br \/>\n                  Previous N_Port_id is = None<br \/>\n            N_Port Node World Wide Name = 0x500143800117ef3d<br \/>\n            N_Port Port World Wide Name = 0x500143800117ef3c<br \/>\n            Switch Port World Wide Name = 0x20810027f8a27cd4<br \/>\n            Switch Node World Wide Name = 0x10000027f8a27cd4<br \/>\n              N_Port Symbolic Port Name = myserv0_fcd0<br \/>\n              N_Port Symbolic Node Name = myserv0_HP-UX_B.11.31<br \/>\n                           Driver state = ONLINE<br \/>\n                       Hardware Path is = 0\/2\/1\/0\/4\/0<br \/>\n                     Maximum Frame Size = 2048<br \/>\n         Driver-Firmware Dump Available = NO<br \/>\n         Driver-Firmware Dump Timestamp = N\/A<br \/>\n                                   TYPE = PFC<br \/>\n                         NPIV Supported = YES<br \/>\n                         Driver Version = @(#) fcd B.11.31.1403 Dec  4 2013<\/p>\n<p>There is a slight error, if you have a fix please share<br \/>\n.\/pathcount_byhbaport.ksh<br \/>\ncalc_path[14]:  wwnportc = wwnportc + 1 : bad number<br \/>\n===========================================<br \/>\n= World wide port name: count<br \/>\n===========================================<br \/>\n| 0x500143800117ef3c : 24    |<br \/>\n| 0x500143800117ef3e : 0    |<br \/>\n| 0x500143800117ef40 : 24    |<br \/>\n| 0x500143800117ef42 : 0    |<br \/>\n===========================================<\/p>\n<p>LDEV info is specific ti Hitachi VSP xpinfo utility. You will have to adapt that code to other storage providers.<\/p>\n<p>.\/pathforalldisks.ksh<br \/>\ncalc_path[14]:  wwnportc = wwnportc + 1 : bad number<br \/>\n===========================================<br \/>\n= World wide port name: count<br \/>\n= Individual device \/dev\/rdisk\/disk172<br \/>\n===========================================<br \/>\n| 0x500143800117ef3c : 1    |<br \/>\n| 0x500143800117ef3e : 0    |<br \/>\n| 0x500143800117ef40 : 1    |<br \/>\n| 0x500143800117ef42 : 0    |<br \/>\n===========================================<br \/>\nLDEV: 03:f3<\/p>\n<p>Link to <a href=\"http:\/\/www.hpux.ws\/scripts\/pathcount_byhbaport.ksh\" title=\"pathcount_byhbaport.ksh\">http:\/\/www.hpux.ws\/scripts\/pathcount_byhbaport.ksh<\/a><\/p>\n<p>Link to <a href=\"http:\/\/www.hpux.ws\/scripts\/pathforalldisks.ksh\" title=\"pathforalldisks.ksh\">http:\/\/www.hpux.ws\/scripts\/pathforalldisks.ksh<\/a><\/p>\n<p>Link to <a href=\"http:\/\/www.hpux.ws\/scripts\/fcdisplaydev.ksh\" title=\"fcdisplaydev.ksh\">fcdisplaydev.ksh<\/a><\/p>\n<p>All scripts are provided with no warranty. Use them at your own risk.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-399","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/399"}],"collection":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=399"}],"version-history":[{"count":0,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hpux.ws\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}