#/bin/bash # monitoring web is running curl www.163.com -I|awk -F ' ' '{print $2}'|sed 's/[a-zA-Z]//g'|grep 200 if [ $? == 0 ] then echo "web is running ok" else echo "web is dead"|mail -s "web is not running" 1306xxx@139.com fi
注:只要返回不是200,就会发邮件告警
缺点:如果返回的是301,就会误判