There is a UNIX command for checking process status, ps.� PS is in all UNIX but the output can vary.� The example below is for HP-UX 11i.

 

The command "ps -ef | grep <your process name here>" would return something like this:

 

$ ps -ef | grep hcimonitord

� 1675 ?������� 402:20 hcimonitord

 

The number "1675" is the process ID.� The 402:20 is the duration the process has been running.

 

So, create a script

 

vi <your script name>

 

#! /usr/bin/ksh

# Purpose check to see if hcimonitord is running

 

# get the process status from UNIX

psValue=$(ps -ef | grep hcimonitord)

if [ $psValue = "" ] ; then

�� echo hcimonitord is not in memory

�� echo "Subject: HCIMONITORD ERROR\\n\\nProcess is not in memory;" | sendmail ME

fi

pidValue=$(echo $psVal|awk '{print $1}')

RunningDurationBefore=$(echo $psVal|awk '{print $3}')

Sleep 60

RunningDurationAfter=$(echo $psVal|awk '{print $3}')

if [ $RunningDurationBefore -eq $RunningDurationAfter ] ; then

�� # if the duration the process has been running is equal

�� # before and after the 60 second sleep, it's not seen as running.

�� echo hcimonitord is not running

�� echo "Subject: HCIMONITORD ERROR\\n\\nProcess is in memory but not running;" | sendmail ME

fi

exit 0

 

 

## end of script

 

make your script executable

�� chmod +x <your script name>

Add your script to crontab;

� crontab -e

 

0,5,10,15,20,25,30,35,40,45,50,55 * * * * <your script name with path>

 

If you are not allowed to run crontab, then you have to get the system admin to set up the cron or allow you to run cron.

 

The 0,5,10,15... tell the cron to run every 5 minutes, you can change that to however frequent you want.

 

Good Luck,

 

Tom Gendron

 

 

 

-----Original Message-----
From: ALVANTHA Arief [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 25, 2004 8:53 AM
To: [EMAIL PROTECTED]
Subject: R�f. : [WhatsUp Forum] Monitoring UNIXProcesses

 


At this time, we wish to receive an alert when one Unix process is down.

We have no idea about the script you meant, have an example of that script ?

Once it run, this script will generate a snmp trap when a monitored process down, isn't it ? pls correct me if I'm wrong.


rgrds,

Arief Alvantha


 

Bruce Shaw <[EMAIL PROTECTED]>
Envoy� par : [EMAIL PROTECTED]

25/02/2004 16:05
Veuillez r�pondre � WhatsUp_Forum

       
        Pour :        "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
        cc :        
        Objet :        [WhatsUp Forum] Monitoring UNIXProcesses




I have to ask the same question I asked earlier in this thread.

What do you mean by "monitor"?  What do you want What's Up Gold to do?

You could monitor processes to see if they die using the scripting I
mentioned earlier in this thread.

You could monitor and graph CPU usage and memory of processes using
hrSWRunPerfCPU.

>Would you pls inform us what we should have (and do) to be able to monitor
Unix processes ?

>>As processes spawn and die (whether through SIG_TERM or other means),
the OIDs are going to change.  The end result is that I don't have a
consistent entity to monitor that guarantees the associated process is
what I expect.


This communication is intended for the use of the recipient to which it is
addressed, and may contain confidential, personal and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take action
relying on it. Any communication received in error, or subsequent reply,
should be deleted or destroyed.


Please visit http://www.ipswitch.com/support/mailing-lists.html
to be removed from this list.

An Archive of this list is available at:
http://www.mail-archive.com/whatsup_forum%40list.ipswitch.com/

Reply via email to