首页 > 代码库 > tomcat健康状态监控并自动重启短信报警
tomcat健康状态监控并自动重启短信报警
#!/bin/shPATH=/usr/local/jdk1.5.0_19/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/binJAVA_HOME=/usr/local/jdk1.5.0_19CLASSPATH=.:/usr/local/jdk1.5.0_19/lib:/usr/local/jdk1.5.0_19/lib/tool.jar:/usr/local/jdk1.5.0_19/lib/dt.jar:LANG=zh_CN.GB18030export JAVA_HOME PATH CLASSPATH LANGtest -e "test.jsp" && rm -f test.jsptest -e "wget-log" && rm -f wget-logwget -b "http://127.0.0.1/portal/test.jsp" > /dev/null 2>&1sleep 2tom=`cat test.jsp`if [ "$tom" == "200" ] ;then echo "`date +%d/%m/%Y:%H:%M:%S` - - tomcatserver is ok!" echo " " echo "-------------------------------------------------------------" exit 0 elif [ "$tom" != "200" ] ;then sh /usr/local/tomcat5/bin/shutdown.sh sh /usr/local/tomcat5/bin/startup.sh echo "`date +%d/%m/%Y:%H:%M:%S` - - tomcatserver is down!restart is successful!" curl "http://sms.api.bz/fetion.php?username=150********&password=******&sendto=150********&message=tomcat服务器down机,重启成功!" echo " " echo "-------------------------------------------------------------"fi
通过判断test.jsp页面的返回值,来确定tomcat状态,实现短信报警(要有飞信账号密码,可以给自己发短信)
加入到系统任务中2分钟检查一次
#vi /usr/local/sbin/checktom.sh
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。