监控网站存活状态
chd='www.5dforum.com/bbs.php'
mailer='[email protected]'
maxrp=3
while :; do
n1=0
c=`ping -c 10 www.5dforum.com |grep received |awk '{print $4}' `
if [ $c == "0" ] ; then
for i in `seq 1 $maxrp`; do
c=`ping -c 10 www.5dforum.com |grep received |awk '{print $4}' `
if [ $c == "0" ] ; then
n1=$i
fi
sleep 10
done
if [ $n1 == $maxrp ]; then
echo "The 5dforum\'s network is down!"|mail -s 5dforum-down $mailer
exit
fi
else
if $(curl $chd|grep 'Discuz!'>/dev/null) ; then
sleep 30
else
n2=0
for i in `seq 1 $maxrp`; do
if $(curl $chd|grep 'Discuz!'>/dev/null) ; then
sleep 30
else
n2=$i
fi
done
if [ $n2 == $maxrp ] ; then
echo "The 5dforum is something wrong, please cheack!"|mail -s 5dforum-down $mailer
exit
fi
fi
fi
sleep 30
done
none