Friday, July 27, 2012

Prechecks.sh shell script example for sysadmin

Someone from my team asked me to write something which will create a report before any SAN uplift and one for post checks also.

and I started adding bits to it as below,


# cat prechecks.sh
#!/usr/bin/ksh
clear
echo "\n"
chk(){
if [ $1 -ne 0 ]
then
echo "$clstr cluster is not installed here\n"
else
echo "$clstr cluster is installed here,Please consider"
fi
}

echo " Script to run before going for SAN uplift just to understand all configuration"

echo "\tSERVER NAME :\t`uname -n`\n\n"
echo "\t\t\tTOTAL VG's  :\t\n`lsvg`\n\n"
echo "\t\t\tTATAL ACTIVE VG's:\t\n`lsvg -o`\n\n"
for i in `lsvg -o`
do
echo "\t\t\tDETAILED INFO OF $i:\n `lsvg $i`\n\n"
for j in `lsvg -p $i|grep hdisk|awk '{print $1}'`
do
#echo "\t\t\tDETAILED INFO OF $i:\n `lsvg $i`\n\n"
echo "\t\t\tATTRIBUTES OF $j:\n"
lsattr -El $j|egrep -e 'queue_depth|reserve_policy'|awk '{print $1": " $2}'
echo "\n\n"
done
done
clstr="HACMP"
/usr/es/sbin/cluster/utilities/clRGinfo 2>/dev/null
ar=`echo $?`
chk $ar
#echo "\n"
clstr="GPFS"
/usr/lpp/mmfs/bin/mmlscluster 2>/dev/null
ar=`echo $?`
chk $ar
exit 0

Hope this will help you!

No comments:

Popular Posts

Is this site helping you ?