check_url

1300阅读 0评论2018-01-15 周士昆
分类:系统运维

# auth by shikun.zhou - EMail:shikun.zhou@bdqn.cn
# Last modified: 2018-1-15
# Filename: check_url.sh
# Description: wget monitoring check_url_active


while true
do
    Mail="shikun.zhou@bdqn.cn"
    FailCount=0
    Retval=0
    GetUrlStatus(){
         for ((i=1;i<=3;i++))
           do
               wget -T 3 --tries=1 --spider {1} >> /dev/null
               [ $? -ne 0 ] && let FailCount+=1;                   
           done
           if [ $FailCount -gt 1 ];then
               Retval=1
               Date=`date +%F" "%H:%M`
               /usr/local/bin/sendEmail -f www@bdqn.cn -t shikun.zhou@bdqn.cn -s pbmail.bdqn.cn -u "check_url" -m "Date: $Date\nProblem:  $url is not running"
           else
               Retval=0
           fi
               return $Retval
    }
for url in `cat url.txt | sed '/^#/d'`
do
     #$GetUrlStatus $url && echo yes || echo no
     GetUrlStatus $url
done
sleep 2m
done
上一篇:Centos 7.3 安装heartbeat
下一篇:check_url