监控WEB页面不正常报警脚本

有时我们遇到这样的情况,网站监控返回值是200,正常,但页面出现错误,这样的情况下,可以用以下思路做下监控,
以下主要是思路,脚本很简单,做成定时 任务 监控WEB 站点页面不正常通过飞信报警

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#!/bin/sh
# Info   : check the web is ok
# Author : dingtm
# CTime  : 2011.11.25
# This script run every 3 minutes

Web_Stats=`curl  www.elain.org  |grep "开源"|wc -l`

if [ $Web_Stats = 0 ]
then
/usr/local/fetion/fetion --sid=1111111 --pwd=1111111 --to=15801111111 --msg-type=1 --msg-utf8="** HTTP WARNING  www.elain.org**"
else
echo "ok" > /dev/null 2>&1
fi

定时任务

1
2
3
4
# Info   : check the web
# Author : dingtm
# CTime  : 2011.11.25
*/3 * * * * /bin/sh /root/scripts/check_web.sh  > /dev/null 2>&1

注:监控页面的关键字,最好找唯一值,这样比较严谨一些,例如我在上面找“开源”两字做关键字

文章目录
,