监控tomcat死活、邮件or短信通知

echo "========tomcat================="
#clear

#(tom的邮件系统支持免费短信通知)
[email protected]  
[email protected]
now=`date '+%Y-%M-%d %H:%m:%S'`
echo "$now"
#echo "..........................正在处理,请稍候............"
pid=`ps -ef|grep tomcat|grep server | sed '/grep/d'|awk '{print "\t"$1}'`
sleep 1
if [ "$pid" != "" ]
   then
   echo "tomcat程序======程序已启动"
else
   echo "tomcat程序无启动,正在启动tomcat请等待......"
   $CATALINA_HOME/bin/startup.sh
   sleep 5
   pid=`ps -ef|grep tomcat|grep server | sed '/grep/d'|awk '{print "\t"$1}'`
         sleep 1
         if [ "$pid" != "" ]
                        then
                        echo "tomcat程序======重新程序已启动"
                        echo "$now tomcat restart!">>/var/log/httpd/tomcat/tomcat`date '+%Y-%m-%d'`.log
                        echo "$now tomcat restart"| mail -s "tomcat info" $mymail
                        echo "$now tomcat restart"| mail -s "tomcat info" $mymail2
                        echo "$now tomcat restart"| mail -s "tomcat info" root@localhost
                else
                        echo "$now tomcat stop,tomcat无法启动,请联系系统管理员">>/var/log/httpd/tomcat/tomcat`date '+%Y-%m-%d'`.log
                        echo "$now tomcat stop!"| mail -s "tomcat info" $mymail
                        echo "$now tomcat stop!"| mail -s "tomcat info" $mymail
                        echo "$now tomcat restart"| mail -s "tomcat info" root@localhost
         fi
fi

你可能感兴趣的:(监控tomcat死活、邮件or短信通知)