Operating System - HP-UX
1752494 Members
5510 Online
108788 Solutions
New Discussion юеВ

Re: HPUX Monitoring Process

 
Mr_Pink
Advisor

HPUX Monitoring Process

Hi
I want to monitor a process every 15 minutes and that if this down notifies to me by mail. As he can help me in that?
Thanks
Yelmo
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: HPUX Monitoring Process

Hi:

Setup a crontask to run every 15-minutes. The task can be as simple as this:

#!/usr/bin/sh
NAME=cron
[ -z "$(UNIX95= ps -C ${NAME} -o pid=)" ] && mailx -s "${NAME} process is down!" yelmo@some.org < /dev/null

Substitute the _name_ of your process for 'NAME' in the script's first line.

Regards!

...JRF...
RamkumarA
Respected Contributor

Re: HPUX Monitoring Process

Hi Yelmo,

You can use the script like below which is for monitoring the syslog daemon...

count=`ps -ef|grep -i syslogd | grep -v grep | wc -l`
if [ $count -eq 0 ]
then
echo "Process:syslogd not running" | mailx -s "process not running"
fi
if [ $count -gt 1 ]
then
echo "More than one instance of syslogd process is running" | mailx -s "More than one instance of process running"
fi

Thanks,
Ramkumar A.
James R. Ferguson
Acclaimed Contributor

Re: HPUX Monitoring Process

Hi (again) Yelmo:

The use of the UNIX95 (XPG4) behavior of 'ps' allows the '-C ' to exactly match a process by its basename. The '-o pid=' tells 'ps' to return any matches with only the process ID and to skip producing a heading. In this case, we build a very simple string to evaulate.

Using 'grep' can lead to false matches.

The XPG4 (UNIX95) behavior should only be set for the duration of the command line. To do otherwise may have undesirable effects for other commands. The feature is resticted to the command line by writing "UNIX95= ps...". That is, "UNIX95="; a whitespace; and then the command without any semicolon.

Regards!

...JRF...