Unix process
Hi,
I have to check 5 Unix processes with the same name. I need an alert, if one process is down. How can I do that?
Thanks in advance
Henry
This discussion has been closed.
Hi,
I have to check 5 Unix processes with the same name. I need an alert, if one process is down. How can I do that?
Thanks in advance
Henry
Comments
Try a script like this and name to for example: my_proc_check
start it like: ./my_proc_check process_name numof_process for example:
./my_proc_check httpd 9 >/var/log/my_proc_check.log 2>&1 &
Then set up serverscheck to watch for process my_proc_check instead. When one httpd process die also my_proc_check will die and you get an alert.
Regards,
Bert
#!/bin/sh
NUMOF_PROC=$2
PROC_NAME=$1
echo "Search for $NUMOF_PROC instance of process: $PROC_NAME."
while [ 1==1 ]; do
if [ "`ps -A | grep $PROC_NAME | wc | awk '{print $1}'`" != "$NUMOF_PROC" ];then
echo "Too few processes, exit...";
exit;
fi
sleep 15
done