Magento服务器监控以及宕机邮件警报
#本脚本请实现yum安装curl和mutt
#请对应修改监控站以及宕机后发送邮箱,下方默认监控www.baidu.com
#如需重启其他服务或者监控不同状态,请自行修改
[email protected] STATUS_OK="200" status="$(curl -o /dev/null -s -m 10 --connect-timeout 10 -w %{http_code} 'http://www.baidu.com/')" if [ $STATUS_OK != $status ] then service mysql restart service varnish restart service nginx restart echo "AutoStart:" $(date +"%y-%m-%d %H:%M:%S") "restart server" > /root/autoreboot.log echo "AutoStart: "$(date +"%y-%m-%d %H:%M:%S")" restart service" | mutt -s "the server is down" $MAIL_TO else echo 'server is ok.' $(date +"%y-%m-%d %H:%M:%S") > /root/autoreboot.log fi