Existing Learnexa Production setup we don't have monitoring for tomcat + solr service if went down

I have written shell script for monitoring

If the service went down . It will automatically bring service UP , Will send an email notification when ever the service went down

Will set every minute cron job in the proddb-slav01 10.166.152.13

We have configured in dev01.learnexa.com it works fine and verified

ssh expprodl@10.166.152.13
* * * * * /bin/sh /home/expprodl/bin/monitor-script-solr-gluster.sh
crontab -e

Shell script

#!/bin/bash
#Author Sudharsan
#Designation sudharsanj
#GNU General Public License

ps="/bin/ps auxw"
gp="grep"
snr="service not running"
null="/dev/null"
email="devops@expertus.com"



$ps | $gp tomcat | $gp -v $gp  > $null

if [  $? -eq 1 ]
then
echo "tomcat $snr" | mail -s "$(hostname) tomcat $snr" $email
fi

$ps | $gp gluster | $gp -v $gp > $null

if [  $? -eq 1 ]
then
  echo "gluster $snr" | mail -s "$(hostname) gluster $snr" $email


fi

$ps | $gp proddb-slav01.pid | $gp -v $gp > $null

if [  $? -eq 1 ]
then
  echo "mysql $snr" | mail -s "$(hostname) mysql $snr" $email


fi