#/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" [email protected] fi
注:只要返回不是200,就会发邮件告警
缺点:如果返回的是301,就会误判
时间: 2024-11-04 07:30:22