#!/bin/sh
echo `date "+%Y-%m-%d-%H:%M:%S"----------------------start-------------------------`
for d in `cat /usr/local/monitor/dz.txt`
do
    z='200 OK'
    a=`curl -I --connect-timeout 30 -m 30 ${d}`
    if [[ $a == *$z* ]]
    then
        echo "ok---${d}"
    else
        t=`date +%Y-%m-%d-%H:%M:%S`
        r='abc@123.com c1@123.cn'
        echo "error---${d}"
        echo ${d:7:200} ${t} 'Not Access! Http Status Not 200' | /bin/mail -s 'Projec Not Access' ${r}
    fi
done
echo `date "+%Y-%m-%d-%H:%M:%S"----------------------end----------------------------`

crontab里面5分钟探测一次

*/5 * * * * sh /usr/local/monitor/monitor_web.sh >> /usr/local/monitor/monitor.log 2>&1

dz.txt里面是要探测的地址
curl探测返回结果不含200的时候,直接发邮件报警;

带符号 * 的表示必填项