1834772 Members
3267 Online
110070 Solutions
New Discussion

Re: process monitoring

 
Ragni Singh
Super Advisor

process monitoring

Hi All,
does anyone have a script to share that does process monitoring for applications. we have a application running and unfortunately one of the processes died today and noone knoew about it. Any help is greatly appreciated and points will be assigned.
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: process monitoring

I guess you could do something like this:

#!/usr/bin/sh

PROCS="proc1 proc2 proc3 proc4 proc5"

for PROCNAME in $PROCS
do
NUMPROC=`ps -ef | grep $PROCNAME | grep -v grep | wc -l`
if [ $NUMPROC != whatever_number_there_should_be ] then
mailx -s "$PROCNAME isn't running" somemail@co.com < "$PROCNAME isn't running right now. you might want to fix it."
fi

done


Or something to that effect.

Note: That script is in no way guaranteed to work. It's off the cuff and is inteded only as an example to guide you in writing your own.
Dietmar Konermann
Honored Contributor

Re: process monitoring

Especially the grep in the ps -ef output is not reliable... imagine a user having a "more swagentd.log" running... the monitor would accept this as a running swagentd. :)

This is somewhat more reliable:

NUMPROC=$(UNIX95= ps -o pid= -C "$PROCNAME" | wc -l)

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Martin Johnson
Honored Contributor

Re: process monitoring

If you have ITO, there are several scripts available as process monitors, such as vp_chk.sh, ds_chk.sh. You could start with vp_chk.sh and modify it to your needs. (We modifed the "ps -e" to "ps -ef" to better pinpoint the processes we were interested in.)

HTH
Marty