disk map script

From: Bill Verzal (BVerzal@KOMATSUNA.COM)
Date: Wed Jan 07 2004 - 15:20:21 EST


I don't know if anyone has something like this already, but I threw this
together today. This is a functional version of the script, but very
simple.

This script will create a report on how individual hdisks are allocated by
physical partitions. I usually use Excel to create color-coded ones, but
they require alot of manual time filling in boxes with different colors.

Feel free to pass this script on and modify it as you wish!

BV

sap80i:/usr/local/bin >cat mkdiskmap.ksh

#!/bin/ksh
#
# Create a disk map of PP's and display on screen.
# Simulates the manual labour performed to create
# the same map in Excel.
#
# Check command line args
#
if [ "$#" -eq "0" ] ; then
   echo "Please specify one or more hdisks"
   exit 1
fi
#
i01=" 1 2 3 4 5 6"
i02="123456789012345678901234567890123456789012345678901234567890"
i03="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#
# row 1 = 1-60
# row 2 = 61-120
# and so on
#
# Create an array of single characters for display purposes
#
charsInArray=`echo "$i03"|wc -c|awk {'print $1'}`
charsInArray=`expr $charsInArray - 1`
arrayCNT=1

while : ; do
   if [ "$arrayCNT" -gt "$charsInArray" ] ; then
      break
   fi
   charArray[${arrayCNT}]=`echo "$i03"|cut -c ${arrayCNT}`
   arrayCNT=`expr $arrayCNT + 1`
done

hdisks="$@"

for hdisk in $hdisks ; do

   if [ ! -r /dev/${hdisk} ] ; then
      echo "Invalid disk ($hdisk) specified - skipping"
      continue
   fi

   echo "Partition map for $hdisk:"
   totalPPs=`lspv $hdisk|grep TOTAL|awk {'print $3'}`
   echo "$totalPPs PPS total on disk"
   x=0

   while [ "$x" -le "$totalPPs" ] ; do
      ppArray[${x}]="."
      x=`expr $x + 1`
   done

   LVs1=`lspv -l $hdisk|awk {'print $1'}`
   LVsCount=`echo "$LVs1"|wc|awk {'print $1'}`
   LVsCount2=`expr $LVsCount - 2`
   LVs2=`echo "$LVs1"|tail -$LVsCount2`
   charcounter=0
   key="Unused: .\n"

   for LV in $LVs2 ; do

      charcounter=`expr $charcounter + 1`
      LVChar="${charArray[${charcounter}]}"
      key="${key}${LV}: $LVChar\n"

      for pp in `lslv -m $LV|grep -v LP|awk {'print $2'}` ; do
         ppArray[${pp}]="$LVChar"
      done

   done

   echo "$i01"
   echo "$i02"

   a=1
   b=1
   while [ "$a" -le "$totalPPs" ] ; do
      echo "${ppArray[${a}]}\c"
      a=`expr $a + 1`
      b=`expr $b + 1`
      if [ "$b" -gt "60" ] ; then
         echo " "
         b=1
      fi
   done

   echo "\n"

   echo "$key"

done

exit 0

============== Sample output below ==============

sap80i:/usr/local/bin >mkdiskmap.ksh hdisk1
Partition map for hdisk1:
542 PPS total on disk
         1 2 3 4 5 6
123456789012345678901234567890123456789012345678901234567890
AIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIBBBBBJJJJCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFGG
GGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHDDDDDDDDDDDDDDDDDCCCCCCCHHHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
HHHHHHHHHHHHH...............................................
..............................JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
JJ

Unused: .
hd5: A
hd10opt: B
hd3: C
hd9var: D
hd6: E
hd8: F
hd4: G
hd2: H
hd1: I
lbin: J

Enjoy!

Bill.
--------------------------------------------------------

"If everything is coming your way, then you are in the wrong lane"

Bill Verzal
AIX Administrator, Komatsu America
(847) 970-3726 - direct
(847) 970-4184 - fax



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:28 EDT