首页 > 代码库 > 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