写了个检测网站运行状态的脚本,发现有时不准确

回复 收藏
我写了一个脚本监控网站状态码的
  1 #!/bin/sh
  2 #author
  3 #function:check all websit is ok or not
  4 #date
  5 weblist=/root/weblist.txt
  6 getdate=`date +"%Y-%m-%d %H:%M:%S"`
  7 webcheckmsg=/root/webcheckmsg.txt
  8 for list in `cat $weblist`
  9 do
10 httpcode=`curl -o /dev/null -s -w %{http_code} "$list"`
11 httptime=`curl -o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\    ntime_total: %{time_total}\n" "$list"|grep time_total|awk -F ":" '{print $2*1000}'`
12 if [ $httpcode = 200 ]||[ $httpcode = 301 ]||[ $httpcode = 302 ]
13 then
14 echo "At $getdate,$list is checked ok!">> $webcheckmsg
15 else
16         echo "At $getdate ,$list is dead,please check it and fixed now"|mail -s "webdead"   xxx@qq.com
17 fi
18 if [ $httptime -ge 10000 ]
19 then
20         echo "At $getdate,$list is timeout !,please check it and fixed now"|mail -s "webtimeout" xxx@qq.com
21 else
22 echo "At $getdate,$list is connect ok!">> $webcheckmsg
23 fi
24 done
发现有时不够准确,不知道是什么问题,
2016-04-22 14:58 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: