#!/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健康状态监控并自动重启短信报警
时间: 2024-10-19 08:04:28