Wednesday, December 18, 2013

storage check script for AIX

echo "HOSTNAME = `hostname`"
echo "OS Level : `uname -a|awk '{print $1, $3}'`"
echo ""
echo "Device,WWN no,SPEED,Status,Target Name,pwwn"
/usr/sbin/lscfg >lscfgout
cat lscfgout|grep fcs|awk '{print $2}'|sort>fcl
for i in `cat fcl`
do
touch tgname
echo $i>fcsname
/usr/sbin/lscfg -vpl $i |grep 'Network Address'|awk -F. '{print $14}'>wwn
speed=`/usr/bin/fcstat $i |grep 'Port Speed (running)'|awk '{print $4}'`
echo "$speed ">speed
if [ -n "$speed" ];then
echo "Active">status
fcsaddr=`cat lscfgout|grep -w $i|awk '{print $3}'`
cat lscfgout|grep $fcsaddr|egrep -v '(fcs|fcnet|fscsi|PowerPath)'|awk '{print $3}'|awk -F- '{print $5}'|sort |uniq>tgwwn
for t in `cat tgwwn`;do cat lscfgout|grep $t|head -1|awk '{print $4,$5,$6,$7,$8,$9,$10}'>>tgname;done

else
echo "Not Active">status
echo " ">tgname
echo " " >tgwwn
fi

/usr/bin/paste -d"," fcsname wwn speed status tgwwn tgname
rm -f tgname
done
rm -f fcsname wwn speed status tgwwn tgname fcl lscfgout