Hello Tobias, Splitting the check as you did is a correct workaround.
Internals: Both status tests in the same service check context trigger the same "status" event type. The "restart" action triggers an implicit "alert" action (thus restart is kind of combo). The alert can be suppressed by the event type, but in this case, you want to be alerted if the status error persists, so the filter is not granular enough in your use case. An alternative workaround could be to suppress the alert and call a custom notification script instead (which may send a mail), something like: --8<-- CHECK PROGRAM MyContainer PATH /bin/check_container my_container noalert foo@bar if status != 0 for 5 cycles then restart if status != 0 for 10 cycles then exec '/usr/local/bin/notify.sh foo@bar' --8<-- Best regards, The M/Monit team > On 9. 2. 2025, at 22:11, Tobias Langner via This is the general mailing list > for monit <[email protected]> wrote: > > Hey, > > I use monit to monitor the health of a bunch of docker containers that > sometimes die/become unhealthy for various reasons, when they are configured > to be restarted by monit, which most of the time fixes the issue. > > I'd like to only be notified by monit when the restart does not fix the > problem and the container is still unhealthy. I thought to configure > something like > > CHECK PROGRAM MyContainer PATH /bin/check_container my_container > if status != 0 for 5 cycles then restart > if status != 0 for 10 cycles then alert > ... > > in the hope that I would only get notified when the script returns a failure > for 10 cycles. However, I also get a notification after five cycles, usually > followed by one immediately after, telling me that everything is good again. > > How can I configure monit in a way to not get notified in such a case? One > way I came up with was to create to separate rules, one to restart only that > uses noalert to entirely supress alerts, and another one to alert. But that > seems like overkill. > > Thanks for your help, best, > > Tobias > > PS: My request is the same as in this thread > <https://lists.nongnu.org/archive/html/monit-general/2014-05/msg00016.html> > but since a) the solution there does not work for me as I generally don't > have an execution failure and b) it is more than 10 years old, I thought to > rather create a new thread. > >
