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="m...@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="m...@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" <jorg...@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="m...@domain.com"
  ps -ef>att.txt
  mail -s "$subject" "$addr" -- -fno-reply@yourdomain< att.txt fi

Reply via email to