2

I need to write a shell script to see if the ADM Process is down we need to get an alert via email. I have done that using the script below. It is working fine if we have installed one ADM server on one machine. My issue is that I have installed 3 ADM servers on one machine and I am not sure how I can write the shell script to trigger an alert in this situation.

script:-

export ADM =`ps -ef  | grep Adm | grep -v grep | wc -l`

if [ $ADM == 0 ];
then
    echo "AdmServer is down on Dev $hostname" | mail -s xxxx.gmail.com
fi

Whenever Adm1 or Adm2 or Adm3 is down we need to get an alert.

5
  • 1
    What is your criterion for deciding that an alert should be sent? Fewer than three Adm processes running? Something else? A combination of events? Commented Oct 15, 2015 at 21:18
  • Whenever Adm1 or Adm2 or Adm3 is down we need to get an alert Commented Oct 15, 2015 at 21:20
  • 3
    Please edit your question to include this information. Do not leave it in the comments for it to get lost. Commented Oct 15, 2015 at 21:21
  • What is chatty comments roaima ? Commented Oct 15, 2015 at 21:22
  • Let us continue this discussion in chat. Commented Oct 15, 2015 at 21:24

2 Answers 2

1

Your script currently counts the number of ADM processes it can find and currently sends an email if the count is zero.

Your new criteria, is that the count should be 3, so if the count is 0 or 1 or 2 you want to send an email.

You need to change line 3

if [ $ADM -lt 3 ];
0
[ 3 -gt "$(ps -Aocomm=|grep -c ADM)" ] &&
mail -s xxxx.gmail.com <<MAIL
AdmServer is down on Dev $hostname
MAIL

I think the above command should work as a substitute for yours.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.