I would like to handle a kind of chain action in monit.
- check for a process and alert immediately.
- restart process after a num of cycles.
My tries (so far):
check process myprocess with pidfile /run/my.pid
start program = "/path/to/binary start" with timeout 60 seconds
stop program = "/path/to/binary stop" with timeout 60 seconds
if not exist for 3 cycles then restart
if not exist then alert
if 3 restarts within 3 cycles then timeout
Does not alert and keeps in state "running" on failing PID but restarts after the 3 cycles.
check process myprocess with pidfile /run/my.pid
start program = "/path/to/binary start" with timeout 60 seconds
stop program = "/path/to/binary stop" with timeout 60 seconds
if not exist for 3 cycles then restart
if children < 1 for 1 cycles then alert
if 3 restarts within 3 cycles then timeout
No alert of children < 1 but restart afer 5.
monit.log
[CEST Aug 1 15:09:30] error : 'myprocess' process is not running
monit summary
Process 'myprocess' Running
Here ist monit -v part:
Existence = if does not exist 3 times within 3 cycle(s) then restart else
if succeeded 1 times within 1 cycle(s) then alert
Pid = if changed 1 times within 1 cycle(s) then alert
Ppid = if changed 1 times within 1 cycle(s) then alert
Children = if less than 1 1 times within 1 cycle(s) then alert else if
succeeded 1 times within 1 cycle(s) then alert
Timeout = If restarted 3 times within 3 cycle(s) then unmonitor
So the question: is it possible to send an alert and change the status to 'not running' within 1 cycle and restart after 3?