Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a colored disk map by filesystem

Disk and filesystem management

Create a colored disk map by filesystem

by  bjverzal  Posted    (Edited  )
Run this script and redirect the output to an HTML file.

#!/bin/ksh
#
# Create a HTML disk map of PP's
# Simulates the manual labour performed to create
# the same map in Excel.
#
# Original created 1/7/2004 by Bill Verzal (bjverzal@yahoo.com)
#
# For best results, redirect output to a .htm/.html file.
#
# This version modified from original by
# Frank Chiavoni <Frank.Chiavoni@OIT.STATE.NJ.US>
#
#
# 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"
colors="#f2c8d0 #2d970b #2e0c7f #6b8a76 #45c53a #37dfb1 #b49618 #0507d6 #32525f #b42363 #84ed57 #c359b7 #103660 #45ec3d #324565 #940964 #51b538"

#
# row 1 = 1-60
# row 2 = 61-120
# and so on
#
# Create an array of single characters for display purposes
#

arrayCNT=1
for colour in $colors
do
colorArray[${arrayCNT}]=$colour
arrayCNT=`expr $arrayCNT + 1`
done

hdisks="$@"
echo "<html><head><title>mdiskmap</title></head><body>"

for hdisk in $hdisks ; do

##Didn't run as root so removed...
if [ ! -r /dev/${hdisk} ] ; then
:
##echo "Invalid disk ($hdisk) specified - skipping"
##continue
fi

echo "<font size=3 color=red><b>Partition map for
$hdisk:</b></font><br>"
totalPPs=`lspv $hdisk|grep TOTAL|awk {'print $3'}`
echo "<font size=3 color=red>$totalPPs PPS total on disk</font><p>"
x=0

defaultColor="#f7f2fd"
while [ "$x" -le "$totalPPs" ] ; do
ppArray[${x}]=$defaultColor
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="<tr><td><font><b><i>Unused</i></b></font></td><td
bgcolor=\"${defaultColor}\"><font
color=\"${defaultColor}\">X....X</font></td></tr>"

for LV in $LVs2 ; do

charcounter=`expr $charcounter + 1`
LVColor="${colorArray[${charcounter}]}"
key="${key}<tr><td><font><b><i>${LV}</i></b></font></td><td
bgcolor=\"${LVColor}\"><font color=\"${LVColor}\">X</font></td></tr>"

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

done

echo "<table><tr>"

a=1
b=1
while [ "$a" -le "$totalPPs" ] ; do
echo "<td bgcolor=\"${ppArray[${a}]}\"><font
color=\"${ppArray[${a}]}\">X</font></td>"
a=`expr $a + 1`
b=`expr $b + 1`
if [ "$b" -gt "60" ] ; then
echo "</tr>"
b=1
fi
done

echo "</tr></table>"

echo "<p><p><table><tr><td colspan=2><font color=red><b>Color"
echo "$key</table>"

done

echo "</body></html>"

exit 0

Then view the created HTML file in your browser of choice. Feel free to change and distribute.

Bill.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top