SUMMARY: Process Monitoring Script

From: bac <bac20000_at_yahoo.com>
Date: Wed, 25 Jul 2001 15:47:37 -0700 (PDT)

Thanks to all who responded, individual names are
mentioned below along with their suggestions.. This is
a kindof long summary which includes scripts that may
possibly be used:

The Question was:

> I need to write a script to monitor a particular
> process, to see if it is running. If it is not, it
> has
> to be started.
>
> This is because one of the processes on my box keeps
> dying.
>
> IS there anything already available for this
> purpose?

The Answer is:

I saw this same question asked earlier on the Tru64
archives but couldnt find any summaries, so here goes
one:

There are several options suggested:

1) Scripts available are:

a) cfengine, suggested by Rob McCauley:
   http://www.gnu.org/software/cfengine/cfengine.html

b) The following script, thanks to Chris Knorr:

#!/bin/sh
SYSTEM=`/usr/bin/uname -n`
USAGE="usage: angel PROCESSNAME"
if [ $# -lt 1 ]; then
        echo ${USAGE}
        exit 1
fi
PROCNAME=$1
pid=`/sbin/ps -e | grep -w ${PROCNAME} | grep -v grep
| grep -v angel |
head -1`
if [ ! -n "${pid}" ]; then
        mail cknorr_at_hops.com <
/usr/users/hopsmain/mvcd_angel.dir/mvcd_down.txt
        /bin/tclsh /usr/users/hopsmain/mvcd.dir/mvcd.tcl &
fi

c) The following suggestion by Ian Mortimer:

A simple way to do this is to start the process from a
script
which runs in an endless loop and restarts the process
if it dies.

Squid comes with a script that does this. Below is
the relevant
part of the script.


# Extract from squid RunCache sh script:

failcount=0
while : ; do
        echo "Running: squid -sY $conf >>
$logdir/squid.out 2>&1"
        echo "Startup: `date`" >> $logdir/squid.out
        start=`date '+%d%H%M%S'`
        squid -NsY $conf >> $logdir/squid.out 2>&1
        stop=`date '+%d%H%M%S'`
        t=`expr $stop - $start`
        if test 0 -le $t -a $t -lt 5 ; then
                failcount=`expr $failcount + 1`
        else
                failcount=0
        fi
        if test $failcount -gt 5 ; then
              echo "RunCache: EXITING DUE TO REPEATED,
FREQUENT
FAILURES" >&2
                exit 1
        fi
        sleep 10
done

d) The following script, by Serguei Patchkovskii:

/usr/bin/ps -e -o pid,command | \
/usr/bin/awk '$2=="/full/path/name/of/your/executable"
{print
"running"}' | \
grep -q running || /full/path/name/of/your/executable
parameters

/Serge.P

e) The following excellent suggestion (one that will
work for me), by Robert, devtty0_at_netscape.net:

run the script via inittab with the respawn
switch. It will perpetually run until you
remove it from inittab. A sample line would be:

xyz:3:respawn:/dir/to/your/script

xyz=a three letter designator. don't duplicate
    any that already exist in inittab
3 =run level in which this script should be
    activated
respawn=do it forever


Hoai TRAN also suggested putting it in inittab with
the respawn option--

f) Kat suggested the following program:

  www.bb4.com

THANK YOU ALL FOR THE SUGGESTIONS...

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
Received on Wed Jul 25 2001 - 22:48:47 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT