Hi,

you can use the test script which will count the processes and return error if 
it doesn't match the expectation.

The script can be something like this (/usr/local/bin/myprocess_test.sh):
--8<--
#!/bin/bash
COUNT=10 #expected count of process instances
if test `ps -ef | grep myprocess | grep -v grep | wc -l` != $COUNT
then
    return 1
else
    return 0
fi
--8<--

and monit configuration something like this:
--8<--
check program myprocess_count with path /usr/local/bin/myprocess_test.sh
   if status != 0 then alert
--8<--

Regards,
Martin



On Apr 24, 2012, at 11:07 AM, Lawrence, Wayne wrote:

> Hi 
> 
> i have a basic check that looks like this
> 
>  check process myprocess
>            matching "myprocess"
>            start = "/etc/init.d/myprocess start"
>            stop  = "/etc/init.d/myprocess stop"
> 
> the process concerned doesn't use a pid file but starts a number of identical 
> instances of the process.
> 
> is there any way in monit i can check how many instances of the process are 
> running within a check and alert if it drops below that number?
> 
> Regards
> 
> Wayne
> 
> 
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to