[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Soft-alert handler and only alert after X cycles
From: |
Martin Pala |
Subject: |
Re: Soft-alert handler and only alert after X cycles |
Date: |
Sun, 15 May 2016 16:30:46 +0200 |
Hello Andrea,
the alert action is implicit (sent even for actions like "exec", and "restart").
The "exec" event type is triggered only, when the program execution failed (in
this case the program was executed without problems), the event type associated
with the CPU usage is "resource" as you observed from the test.
Possible workaround is to split the configuration into two service containers:
one service container will run all test with alerts disabled, the second is
allowed to send alerts:
--8<--
set alert address@hidden but not on { instance }
# first service container with NO alerts
check system $HOST
if cpu usage (user) > 70% then exec '/etc/monit_soft.sh' else if succeeded
then exec '/etc/monit_soft.sh'
noalert address@hidden #note: override the global alert settings: disable
all alerts for address@hidden
# second service container with alert enabled (any test in this container will
send alert to all "set alert <mail>" targets)
check system $HOST-alarm
if cpu usage (user) > 70% for 5 cycles then alert
--8<--
Best regards,
Martin
> On 15 May 2016, at 13:27, Andrea V. <address@hidden> wrote:
>
> Hello everybody!
>
> I have a problem with Monit I am really stuck at, despite several tests and
> simulation.
> I reduced the problem to the following:
>
> /etc/monit/monitrc:
> ----
> set alert address@hidden but not on { instance }
>
> check system simple-TEST-system
> if cpu usage (user) > 70% then exec '/etc/monit_soft.sh' else if
> succeeded then exec '/etc/monit_soft.sh'
> if cpu usage (user) > 70% for 5 cycles then alert
> ----
>
> What I want to achieve is to execute a script upon cpu usage (user) > 70%
> across the system, and only after 5 cycles and only then to alert via a mail.
> The actual result though is that I receive a mail on the first cycle already
> with the following content:
>
> ----
> Resource limit matched Service simple-TEST-system
>
> Date: Sun, 15 May 2016 13:15:55
> Action: exec
> Host: simple-TEST-system
> Description: cpu user usage of 76.0% matches resource limit [cpu user
> usage>70.0%]
>
> Your faithful employee,
> Monit
> ----
>
> (note the Action: exec)
> And again after 5 cycles I receive another mail with:
>
> ----
> Resource limit matched Service simple-TEST-system
>
> Date: Sun, 15 May 2016 13:16:50
> Action: alert
> Host: simple-TEST-system
> Description: cpu user usage of 97.9% matches resource limit [cpu user
> usage>70.0%]
>
> Your faithful employee,
> Monit
> ----
>
> This time the action is "alert" and is the only mail I would like to receive.
> What I also tried is to filter out the 'exec' action by specifying:
>
> set alert address@hidden but not on { instance, exec }
>
> This didn't work either to deny the first mail to come in. On the other hand,
> specifying a filter on 'resource' would deny any alert to be mailed upon that
> kind of check.
>
> So: how do I prevent monit to alert for an action that just executes a script
> a form of soft-handling an issue and only properly alert after a few cycles?
>
> Any suggestion will be really appreciated, this problem has been driving me
> crazy for a week now.
>
> Many thanks!
>
> Andrea
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general