# more monotor_www_bbs_webserver.sh
#!/bin/bash
site1=www.sdtest.com
site2=bbs208.sdtest.com
site3=bbs209.sdtest.com
site4=bbs210.sdtest.com
status=200
while :
do
logdate=$(date +%Y'-'%m'-'%d' '%H':'%M':'%S)
for site in $site1 $site2 $site3 $site4;do
status=`curl -s --head http://$site | awk '/HTTP/ {print $2}'`
if [ "$status" == "200" ]
then
echo "$logdate $site is running."
else
echo "$logdate $site seems error and the first stats still is $status"
status=`curl -s --head http://$site | awk '/HTTP/ {print $2}'`
if [ "$status" != "200" ]
then
echo "$logdate $site seems error and the second stats still is $status"
echo "$logdate $site seems error and the second stats still is $status" | mail -s "$site not running,please check " 186*****30@www.com.cn
fi
fi
done
sleep 300
done
# nohup /monotor_www_bbs_webserver.sh &