The following script generates a mapping of the Hitachi Multi-path drives and provides all information necessary to identify a drive. The information includes PVID, Location Code, WWN, LDEV Number, HDLM device name, Hdisk device name, Major Number, and Volume Group.

#!/usr/bin/ksh
################################################################
#### 
#### Program: dlmfdrvmap.sh
####
#### Description: The purpose of this script is to provide a
#### mapping of the Hitachi SAN disks to show the various
#### identifiers associated with each disk.  These identifiers
#### include:
####
####     PVID
####     Location Code
####     Hdisk Name
####     HDLM Name
####     WWN
####     LDEV Number
####     Volume Group
####     Major Number
####
#### Author: Dana French (dfrench@mtxia.com)
####
#### Requirements: Needs execute permission for the "dlnkmgr" command
####
################################################################
cd /usr/DynamicLinkManager/bin
lspv | grep dlmfdrv | grep -v dlmfdrvio |
while read -- HDISK PVID VGNAME STATE
do
  MAJOR=""
  LOC=""
  ls -l /dev/${VGNAME} 2>/dev/null |
    IFS="${IFS}," read -- PERMS LINKS OWNER GROUP MAJOR MINOR REMAIN
  print -- "\n${HDISK}  ${PVID}  ${VGNAME}  ${STATE}  ${MAJOR:+VGmajor#:${MAJOR}}"
  /usr/DynamicLinkManager/bin/dlnkmgr view -drv |
      grep " ${HDISK} " |
  while read -r -- LINE
  do
    print -r -- "${LINE}"
    print -r -- "${LINE}" | read -r -- DNBR DLMDISK DDISK LDEV
    LOC="${LOC}$( lscfg -l ${DDISK} | awk '{ print $2, $1 }' )\\n"
  done
  print -- "${LOC}"
done


This script generates HTML code containing the SAN Disk associations for each SMART Instance Server. The information allows the AIX administrator to boot an AIX host from a specific "rootvg" and to attach SMART instances to that host.



#!/usr/bin/ksh93
################################################################
#### 
#### Program: dlmfdrvhtml.sh
#### 
#### Description: The purpose of this script is to
#### obtain several parameters that identify the disk drives
#### associated with an AIX system.  The drives may be
#### internal or exist on the SAN.  The identification
#### parameters provide the AIX administrator with the
#### ability to boot the AIX machines from a selected drive,
#### and provide the ability to attach selected drives to an
#### AIX system. 
#### 
#### Author: Dana French
#### 
#### Date: 20041004
#### 
################################################################
################################################################
function printCells {
  LDEVLNK[${PV}]="${LDEVLNK[${PV}]#, }"
  print "<P>
  <TR>
    <TD>${1:-&nbsp;}</TD>
    <TD>${VGID[${PV}]}</TD>
    <TD>${LOCID[${PV}]:-&nbsp;}</TD>
    <TD>${PVID[${PV}]:-&nbsp;}</TD>
    <TD>${PV:-&nbsp;}</TD>
    <TD>${WWNLIST[${PV}]:-&nbsp;}</TD>
    <TD>${DLMLNK[${PV}]:-&nbsp;}</TD>
    <TD>${LDEVLNK[${PV}]:-&nbsp;}</TD>
  </TR>
</P>"
  return 0
}
################################################################


#### 
#### From the list of physical volumes, extract the volume group,
#### PVID, and PV Name. Save these values to associative arrays
#### for later use.  Also extract the Location ID from the
#### lscfg command using each PV name.
#### 

unset LOCID
typeset -A LOCID
unset PVID
typeset -A PVID
unset VGID
typeset -A VGID

#   grep -vi "[      ]none[  ]" |
lspv |
  while read -r -- PV PVNUM VG STATUS
  do
    LOCID[${PV}]=$( lscfg -l "${PV}" | awk '{ print $2 }' )
    PVID[${PV}]="${PVNUM}"
    VGID[${PV}]="${VG}"
  done

#### 
#### Using the Hitachi "dlnkmgr" command, obtain the list of 
#### dlm disks and their association with hdisks.  Save these
#### values to associative arrays indexed by the DLM disk name.
#### Also save the LDEV number.  Again save the Location ID
#### for each of the DLM disks and the location ID for each
#### associated hdisk.
#### 

unset DLMLNK
typeset -A DLMLNK
unset LDEVLNK
typeset -A LDEVLNK

 /usr/DynamicLinkManager/bin/dlnkmgr view -drv | grep "dlmfdrv" |
  while read -r -- PATHID HDEV HDISK LDEV
  do
    DLMLNK[${HDEV}]="${LDEV}"
    LDEVLNK[${HDEV}]="${LDEVLNK[${HDEV}]}, ${HDISK}"
    [[ "_${HDEV}" != "_" ]] &&
        LOCID[${HDEV}]=$( lscfg -l ${HDEV} | awk '{ print $2 }' )
    [[ "_${HDISK}" != "_" ]] &&
        LOCID[${HDISK}]=$( lscfg -l ${HDISK} | awk '{ print $2 }' )
  done

# print "LOCID = ${!LOCID[@]}"

#### 
#### Extract the World Wide Name and LUN ID for each Hitachi Disk.
#### Save these values to an assoicate array for later use.
#### 

unset WWNLIST
typeset -A WWNLIST
for PV in "${!LOCID[@]}"
do
    unset TMP
    TMP=( $( lsattr -El "${PV}" -F value -a ww_name -a lun_id 2>/dev/null ) )
    WWNLIST[${PV}]="${TMP[0]#0x}-L${TMP[1]#0x}"
    [[ "_${WWNLIST[${PV}]}" = "_-L" ]] && unset WWNLIST[${PV}]
done

#### 
#### Write HTML TABLE code for each of the saved values.
#### 

print "<P>
<TABLE Border=\"2\" Cellspacing=\"2\" Cellpadding=\"2\">
  <P>
    <TR Rowspan=\"1\">
        <TH Bgcolor=\"lightblue\" Align=\"left\" Valign=\"middle\" Colspan=\"8\">
            <FONT Size=\"4\" Color=\"darkblue\">
Machine ID: $( hostname )
            </FONT>
        </TH>
    </TR>
  </P>
  <P>
    <TR Rowspan=\"1\">
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
Resource<BR>Group
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
Volume<BR>Group
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
Location<BR>ID
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
PVID
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
Active<BR>Disk
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
WWN
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
LDEV
            </FONT>
        </TH>
        <TH Bgcolor=\"lightblue\" Align=\"center\" Valign=\"middle\" Colspan=\"1\">
            <FONT Size=\"4\" Color=\"darkblue\">
Inactive<BR>Disk
            </FONT>
        </TH>
    </TR>
  </P>
"

#### 
#### Extract the disk identification parameters
#### from the saved values and output the information in an
#### HTML table format.  The table columns consist of the
#### Resource Group, Volume Group, Location ID, Physical
#### Volume ID, Active Disk Name, World Wide Name, LDEV
#### Number, and Inactive Disk Name.
#### 

for PV in "${!PVID[@]}"
do
#   [[ "_${VGID[${PV}]}" != _*rootvg* ]] && continue
  [[ "_${PV}" != _*hdisk* ]] && continue
  printCells "$( hostname )"
done

for PV in "${!PVID[@]}"
do
#   [[ "_${VGID[${PV}]}" = _*rootvg* ]] && continue
  [[ "_${PV}" = _*hdisk* ]] && continue
  printCells "${VGID[${PV}]%%*([_])vg}"
done

print "</TABLE></P>"