码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat健康状态监控并自动重启短信报警

时间:2014-07-14 22:49:52      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   java   color   os   

#!/bin/sh

PATH=/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/bin
JAVA_HOME=/usr/local/jdk1.5.0_19
CLASSPATH=.:/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.GB18030
export JAVA_HOME PATH CLASSPATH LANG

test -e "test.jsp" && rm -f test.jsp
test -e "wget-log" && rm -f wget-log

wget -b "http://127.0.0.1/portal/test.jsp" > /dev/null 2>&1
sleep 2

tom=`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

tomcat健康状态监控并自动重启短信报警,布布扣,bubuko.com

tomcat健康状态监控并自动重启短信报警

标签:style   blog   http   java   color   os   

原文地址:http://www.cnblogs.com/feelgood/p/3842381.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!