!/bin/bash
while true
do
Master=10.0.0.10
Backup=10.0.0.11
Vip=10.0.0.100
M_num01=/bin/ping -c 2 -W 3 $Master >/dev/null 2>&1 ; echo $?
B_num01=/bin/ping -c 2 -W 3 $Backup >/dev/null 2>&1 ; echo $?
if [ "B_num01" -ne 0 ];then
exit 1
fi
M_num02=ssh $Master ip add|grep $Vip|wc -l
B_num02=ssh $Backup ip add|grep $Vip|wc -l
if [ "$M_num02" -ne 0 -a "$B_num02" -ne 0 ];then
echo "The server suffered a brain fracture"
else
echo "Server normal"
fi
done
网友评论