您的位置:首页 > 运维架构

每5分钟监控web服务器状态

2011-09-29 15:23 369 查看
# 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 &
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: