0

I've written a script which sends me an sms notification. I call with exec action in monit test. It works, but I'm getting overwhelmed by messages. Is there a way to suppress sending subsequent messages if check fails until it succeeds?

Here is the monit config file:

check system my_host
    if loadavg (1min) > 3 then alert
    if loadavg (1min) > 3 then exec "/usr/local/sms_notifier/sms_notifier.php all cpu load average exceeds 3" as uid nobody and gid sms
    if loadavg (5min) > 2 then alert
    if memory usage > 90% then alert
    if memory usage > 90% then exec "/usr/local/sms_notifier/sms_notifier.php all memory usage exceeds 90%" as uid nobody and gid sms
    if cpu usage (user) > 70% then alert
    if cpu usage (system) > 30% then alert
    if cpu usage (wait) > 30% then alert
Dmitry Vyal
  • 109
  • 2
  • Please show your monit configuration file. – ewwhite Oct 03 '12 at 16:00
  • Maybe add something like `[[] [TIMES WITHIN] CYCLES]` to your tests so you only trigger the alert if your issue is continuous, and not an intermittent spike? Or perhaps adjust your thresholds. – Zoredache Oct 03 '12 at 16:39
  • loadavg 3 for a minute is the precise sign of something terrible in my case. I want to be noticed immediately, but I really don't need dozens of sms for one such event. Sole message is good enough. – Dmitry Vyal Oct 03 '12 at 19:10

1 Answers1

0

You need to add "cycles" to your config.

check system localhost
    if loadavg (15min) > 8 for 10 cycles then alert

See the Monit service test documentation.

ewwhite
  • 197,159
  • 92
  • 443
  • 809
  • Well, I'm not talking about alerts here. They are not repeated. I get one message when an event occurs and another when check succeeds again. Execs keep spamming me. I didn't set cycles option because it would increase the latency and I want to be notified asap. – Dmitry Vyal Oct 03 '12 at 19:03