监控tomcat某个Java服务挂了并发送邮件通知实践

增加shell脚本

#!/bin/bash
n=`curl -I -s  http://127.0.0.1:8088/projectName/index.jsp | grep "HTTP/1.1 200" | wc -l`
if [ $n -ne 1 ]
    then
      title=‘projectName监控通知‘
      notice=‘[www.xxx.com] projectName is not available‘
      echo $notice
      echo  $notice | mail -s $title  

fi

然后使用crontab没隔5分钟执行shell脚本

相关推荐