tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darryl Lewis <darryl.le...@unsw.edu.au>
Subject Re: How to detect down of tomcat.
Date Tue, 22 Mar 2011 08:05:21 GMT
This needs to be run as root
Put it in a cron job to fire every minute

#!/bin/sh
DOWN=0
read DOWN <status.txt

if [ $DOWN -eq 1 ]
  then
   if [ `ps -ef|grep tomcat|grep -v grep|wc -l` -gt 0 ]
     then
    NOW=`date`
    subject="tomcat recovered $NOW"
    address="me@domain.com"
    ps -ef|grep tomcat5 >att.txt
    mail -s "$subject" "$addr" -- -fno-reply@yourdomain< att.txt fi
    DOWN=0
fi

if [ `ps -ef|grep tomcat|grep -v grep|wc -l` -lt 1 ]
  then
  NOW=`date`
  subject="tomcat down $NOW"
  address="me@domain.com"
  ps -ef|grep tomcat5 >att.txt
  mail -s "$subject" "$addr" -- -fno-reply@yourdomain< att.txt fi
  DOWN=1
  service tomcat5 restart
fi
echo $DOWN >status.txt





On 22/03/11 5:54 PM, "Jorge Infante Osorio" <jorgeio@uci.cu> wrote:

#!/bin/sh
if [ `ps -ef|grep tomcat|grep -v grep|wc -l` -lt 1 ]
  then
  NOW=`date`
  subject="tomcat down $NOW"
  address="me@domain.com"
  ps -ef>att.txt
  mail -s "$subject" "$addr" -- -fno-reply@yourdomain< att.txt fi

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message