[Linux-cluster] Network Monitor
amrossi at linux.it
amrossi at linux.it
Tue Nov 6 20:31:30 UTC 2007
Hi all,
i've Failover Domain (two nodes) with Red Hat Cluster Suite (RHEL5).
I'm writting little script to control network status; this script running
under rgmanager with other script (apache|tomcat|..).
################################################################
#!/bin/bash
DEVICE="eth0"
hosts="www.google.it www.iol.it www.ansa.it www.virgilio.it"
MINIMO="2"
STATUS="true"
status() {
ip addr show | grep $DEVICE | grep "NO-CARRIER" > /dev/null 2>&1
if [ "$?" = "0" ] ; then
echo "Warning. Network Down."
STATUS="false"
else
c=0
for host in $hosts ; do
fping -a $host > /dev/null 2>&1
if [ "$?" -eq "1" ] ; then
echo $((++c)) > /dev/null 2>&1
if [ "$c" -eq "$MINIMO" ] ; then
echo "Warning. Network Down."
STATUS="false"
fi
fi
done
fi
}
start() {
status
}
stop() {
status
}
restart() {
status
}
ip addr show | grep $DEVICE > /dev/null 2>&1
if [ "$?" != "0" ] ; then
echo "$DEVICE not Found"
STATUS="false"
fi
if [ -z "$1" ] ; then
command="status"
else
command="$1"
fi
case "$command" in
'status')
status
;;
'start')
start
;;
'stop')
stop
;;
'restart')
restart
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
STATUS="false"
;;
esac
if [ "$STATUS" == "true" ] ; then
exit 0
else
exit 1
fi
########################################################################
It's OK?
More information about the Linux-cluster
mailing list