while true; do
if ! ping -c 1 -w 1 $TARGET > /dev/null; then
((MISSED++))
else
if [ $MISSED -gt 2 ]; then
#提醒服务器恢复
echo `date +%F\ %T` $TARGET resumed.
fi
MISSED=0
fi
if [ $MISSED -eq 2 ]; then
#提醒服务器在1秒钟内没有回应
echo `date +%F\ %T` $TARGET HAS NO RESPONSE!
fi
sleep $PAUSE
if [ $MISSED -gt 253 ]; then
MISSED=5
fi
done
[/code:1]