Hallo, based on your sample check program script with path "/usr/local/etc/monit/scripts/test.sh" start program "/usr/local/etc/monit/scripts/test.sh start" stop program "/usr/local/etc/monit/scripts/test.sh stop" if 2 restarts within 10 cycles then alert if status != 0 then restart
and monitrc with "set daemon 60", the daemon check cycle time. [2021-01-12T23:15:31+0100] error : 'script' status failed (1) -- program test script at Di 12 Jan 2021 23:14:31 CET for script [2021-01-12T23:15:31+0100] info : 'script' trying to restart [2021-01-12T23:15:31+0100] info : 'script' stop: '/usr/local/etc/monit/scripts/test.sh stop' [2021-01-12T23:15:37+0100] info : 'script' start: '/usr/local/etc/monit/scripts/test.sh start' [2021-01-12T23:16:42+0100] error : 'script' service restarted 2 times within 6 cycles(s) - alert [2021-01-12T23:16:42+0100] info : 'script' status succeeded (0) -- program test script at Di 12 Jan 2021 23:15:42 CET for script And your question > 1. Why success email arrives two minutes after failure? start/stop programs > are > pretty quick and execution time take few seconds. I got a "Status failed Service script" mail and after a minute the "Status succeeded Service script" mail from my local mail server. My suggestion, check your mail server or the cycle time. > 2. Is there a way to configure monit not to alert me unless 2 restarts happen > within 10 cycles and status is still not zero? >From my point of view, you can not configure this. With regards, Lutz
