首页 > Web开发 > 详细

check web status

时间:2015-09-12 01:01:18      阅读:323      评论:0      收藏:0      [点我收藏+]

#!/bin/bash

sendmail() {

/usr/local/bin/sendEmail -f xyxsender@163.com -t test@relearn.com -s smtp.163.com -u "SERVER 192.168.31.$i" -xu xyxsender@163.com -xp "123456" -m "Alert: web 192.168.31.$i can‘t access"

}


while :

do

    for i in {129,202,130}

    do

        status_code=`curl -I -o /dev/null -s -w "%{http_code}\n" http://192.168.31.$i`

        if [ $status_code -ne 200 ]

        then

            sendmail

            echo `date` >> /var/log/WebAlert.log

            echo "Alert Email has been sent" >> /var/log/WebAlert.log

            echo "---------------------------------------------"

        fi

    done

sleep 10

done


本文出自 “态度决定一切” 博客,请务必保留此出处http://relearn.blog.51cto.com/2605709/1693920

check web status

原文:http://relearn.blog.51cto.com/2605709/1693920

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!