DiskToLD
From My Admin Page
#!/bin/ksh ####################################### ### if set, one line output per device OUTPUT=1 ### if set, looks up by vxdisk device DISK_TYPE=1 ####################################### x=-1 ; SCCLI_CMD="/usr/sbin/sccli" CTLR=`cfgadm -o show_FCP_dev | egrep -v '(c1|Ap_Id|unconfigured)' | head -1 | awk '{print $1}'` SCCLI_DEV=`$SCCLI_CMD -l | awk '{print $1}'` ; SCCLI="$SCCLI_CMD $SCCLI_DEV" # Gather SCCLI info into files PARTITIONS=/var/tmp/partitions.txt PORT_WWNS=/var/tmp/port_wwns.txt LUNS=/var/tmp/luns.txt $SCCLI show partitions > $PARTITIONS 2> /dev/null $SCCLI show port-wwns > $PORT_WWNS 2> /dev/null $SCCLI show luns > $LUNS 2> /dev/null # Lookup Disk Device if [ $DISK_TYPE -eq 1 ] ; then set -A VXDEVICES `vxdisk list | grep SUN35100 | awk '{print $1}'` DEVICES=`echo ${VXDEVICES[*]} | xargs vxdisk list | egrep "^$CTLR" | awk '{print $1}'` else DEVICES=`iostat -En | grep "^$CTLR" | awk '{print $1}' | sed 's/Soft/s2/g'` fi if [ $OUTPUT -eq 1 ] ; then echo printf "%-6s %-25s %-12s %-11s %-9s\n" "LD/LV" "Sun Disk Device" "ID-Partition" "VXDisk" "Size" printf "%-6s %-25s %-12s %-11s %-9s\n" "-----" "---------------" "------------" "------" "----" fi # Examine each Disk Device for i in $DEVICES ; do LUXADM_DISPLAY="luxadm display /dev/rdsk/$i" LUX_DISP_OUT=`$LUXADM_DISPLAY | grep '\/devices' | head -1` # if luxadm doesn't output anything re-loop if [ -z $LUX_DISP_OUT ] ; then (( x=x+1 )); continue; fi # Get WWPN (using 'typeset -u' to make uppercase) typeset -u WWPN ; WWPN=`echo $LUX_DISP_OUT \ | awk -F, '{print substr($(NF-2),length($(NF-2)) - 15,length($(NF-2)))}'` # Get LUN number LUN=`echo $LUX_DISP_OUT | awk -F, '{print $(NF-1)}' | awk -F\: '{print $1}'` LUN_DEC=`echo $((16#$LUN))` # Match WWPN to port and channel on 3510 PT_CH=`grep $WWPN $PORT_WWNS| awk '{print substr($0,1,6)}'` PT_CH_LUN=`echo "$PT_CH\c";printf "%+4s" $LUN_DEC` # Get ID-Partition and ld#-## info PART_ID=`grep "$PT_CH_LUN" $LUNS | head -1 | awk '{print $5}'` LD=`grep $PART_ID $PARTITIONS | awk '{print $1}'` LD_SIZE=`grep $PART_ID $PARTITIONS | awk '{print $3}'` # PRINTING: if OUTPUT=1 all in one line per device if [ $OUTPUT -eq 1 ] ; then printf "%-6s %-25s %-12s %-11s %9s\n" $LD $i $PART_ID ${VXDEVICES[$(( x=x+1 ))]} $LD_SIZE else echo "$i: \c"; $LUXADM_DISPLAY | grep '\/devices' | awk 'NR>1{print $1}' echo "WWPN: $WWPN" echo " LUN: $LUN (hex) $LUN_DEC (dec)" echo "ID-Partition: $PART_ID" echo "LD: $LD" echo "Size: $LD_SIZE" fi done rm $PARTITIONS $PORT_WWNS $LUNSRTITIONS $PORT_WWNS $LUNS 2> /dev/null