I wrote up a script (/usr/local/sbin/processname) that generates a "0" return code if there is one process running, otherwise it returns "1". So if the daemon is not running or has more than 1 process I should get a 0. That's good so either state of not running and running more than one instance should generate a restart.

In /etc/monit.d/processname I have:

check program processname with path "/usr/local/sbin/processname"
    if status != 0 then
    start program = "/usr/sbin/service processname start"
    stop program = "/usr/sbin/service processname stop"
    restart

When I test using "monit -t" I get:

/etc/monit.d/processname:3: syntax error '/usr/sbin/service'

This is the first time I've tried to do any custom setup in monit so I'm betting I'm just not getting the right syntax is just the right spot.

On 08/12/2016 11:14 AM, SZÉPE Viktor wrote:
You may also use `pgrep`

Be aware that there is no shell execution in `program with path` you have to put your script in a file.


Idézem/Quoting Tino Hendricks <[email protected]>:

I would go for a simple script containing something like

ps aux | grep the_process_name | grep -v grep | wc -l

and check for the number.

Tino

Am 12.08.2016 um 14:12 schrieb Stephen Berg (Contractor) <[email protected]>:

Is there a way to monitor a daemon that is supposed to have exactly one process showing. If the count is above one the daemon needs to be restarted.


--
Stephen Berg
Systems Administrator
NRL Code: 7320
Office: 228-688-5738
[email protected]


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


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



SZÉPE Viktor


--
Stephen Berg
Systems Administrator
NRL Code: 7320
Office: 228-688-5738
[email protected]


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

Reply via email to