Cluster HeartBeat Health Status Check Script


This  script has written for  check  cluster  heartbeat  status . It ‘ll check  cluster  HB  for  ;

  • Oracle  Solaris  Cluster
  • HP-UX ServiceGuard
  • Veritas  Cluster
  • Red Hat  Cluster

Also  it supports these  operating systems;

  • Oracle  Solaris 10-11
  • HP-UX  11.23,11.31
  • Red Hat 5-6

 

#!/bin/ksh

OS=`uname -s`

case "$OS" in
"SunOS")
if [ -f /opt/VRTS/bin/hastatus ]
then
for i in $(cat /etc/llttab |grep ether|awk '{print $2}')
do
if /opt/VRTS/bin/lltstat -nvv |grep $i|head -2|/usr/xpg4/bin/grep -wq "DOWN" >/dev/null 2>&1
then
DEG=`/opt/VRTS/bin/lltstat -nvv |grep $i|head -2|/usr/xpg4/bin/grep -w "DOWN"|awk '{print $1}'|sort -u`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "NOK" "|" "$DEG" "]"
else
DEG=`/opt/VRTS/bin/lltstat -nvv |grep $i|head -2|/usr/xpg4/bin/grep -w "UP"|awk '{print $1}'|sort -u`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "OK" "|" "$DEG" "]"
fi
done
fi
if [ -f /usr/cluster/bin/clintr ]
then
for i in $(/usr/cluster/bin/clintr status|grep -w "online"|awk '{print $1}'|grep `hostname`|cut -d ':' -f 2,2)
do
if /usr/cluster/bin/clintr status|grep `hostname`|grep $i|/usr/xpg4/bin/grep -qw "faulted" >/dev/null 2>&1
then
DEG=`echo $i`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "NOK" "|" "$DEG" "]"
else
DEG=`echo $i`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "OK" "|" "$DEG" "]"
fi
done
fi

;;
"Linux")
if [ -f /opt/VRTS/bin/hastatus ]
then
for i in $(cat /etc/llttab |grep ether|awk '{print $2}')
do
if /opt/VRTS/bin/lltstat -nvv |grep $i|head -2|grep -wq "DOWN" >/dev/null 2>&1
then
DEG=`/opt/VRTS/bin/lltstat -nvv |grep $i|head -2|grep -w "DOWN"|awk '{print $1}'|sort -u`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "NOK" "|" "$DEG" "]"
else
DEG=`/opt/VRTS/bin/lltstat -nvv |grep $i|head -2|grep -w "UP"|awk '{print $1}'|sort -u`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "OK" "|" "$DEG" "]"
fi
done
fi

if [ -f /etc/cluster/cluster.conf ]
then
for i in $(cat /etc/cluster/cluster.conf|grep failoverdomainnode|cut -d '"' -f 2,2|grep `hostname`)
do
etherXIP=`cat /etc/hosts|grep $i|grep -v '#'|awk '{print $1}'`
etherX=`ip a|grep $etherXIP|awk '{print $NF}'`
if /sbin/ethtool $etherX|grep -w "Link detected"|cut -d ':' -f 2,2|grep -qw "no" >/dev/null 2>&1
then
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "NOK" "|" "$etherX" "]"
else
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "OK" "|" "$etherX" "]"
fi
done
fi
;;
"HP-UX")
if [ -f /opt/VRTS/bin/hastatus ]
then
for i in $(cat /etc/llttab |grep ether|awk '{print $2}')
do
if /opt/VRTS/bin/lltstat -nvv |grep $i|head -2|grep -wq "DOWN" >/dev/null 2>&1
then
DEG=`/opt/VRTS/bin/lltstat -nvv |grep $i|head -2|grep -w "DOWN"|awk '{print $1}'|sort -u`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "NOK" "|" "$DEG" "]"
else
DEG=`/opt/VRTS/bin/lltstat -nvv |grep $i|head -2|grep -w "UP"|awk '{print $1}'|sort -u`
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "OK" "|" "$DEG" "]"
fi
done
fi
if [ -f /usr/sbin/cmviewcl ]
then
if /usr/sbin/cmviewcl -v|egrep 'Primary|Alternate'|grep -qw "down" >/dev/null 2>&1
then
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "NOK" "|" "--" "]"
else
printf "%-20s%-20s%-20s%-20s%-20s%-20s\n" "`hostname`" "|" "OK" "|" "--" "]"
fi
fi
;;
esac

exit 0

 

# ksh /tmp/clusterhb
TESTSERVER| OK | eth13 ]
TESTSERVER| OK | eth17 ]
TESTSERVER| OK | bond0 ]

 

Tagged In:

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me