monit send alert for different cycles fails to different e-mail addresses

49 views Asked by At

how can I set alert for different cycles fails to different users (something like that) for the same service in monit?

I have tried the config like his below.

check host "Cluster0 Admin Panel" with address 192.168.5.80
          if failed port 4443 protocol https with timeout 10 seconds for 3 cycles then alert [email protected]
          if failed port 4443 protocol https with timeout 10 seconds then alert [email protected]

But syntax error occured on the e-mail addresses lines.

this one sent emails to both user at 1th cycle and 3th cycle

check host "Cluster0 Admin Panel" with address 192.168.5.80
          if failed port 4443 protocol https with timeout 10 seconds for 3 cycles then alert 
                alert [email protected]
          if failed port 4443 protocol https with timeout 10 seconds then alert 
                alert [email protected]
1

There are 1 answers

0
lutzmad On

This is the way how Monit handle the alert statement, see https://mmonit.com/monit/documentation/monit.html#Setting-an-alert-recipient

You can set the alert target (a email) using the global "set alert" statement or the "alert" statement in the context of a service entry. But you can not set a email address in a context of a test. You can check the behaviour by using "monit -v" to get some Monit internal information about the configuration.

Remote Host Name      = Cluster0 Admin Panel
 Address              = 192.168.5.80
 Monitoring mode      = active
 On reboot            = start
 Port                 = if failed [192.168.5.80]:4443 type TCP/IP protocol HTTP with timeout 10 s using TLS then alert
 Port                 = if failed [192.168.5.80]:4443 type TCP/IP protocol HTTP with timeout 10 s using TLS for 3 cycles then alert
 Alert mail to        = [email protected]
   Alert on           = All events
 Alert mail to        = [email protected]
   Alert on           = All events

This looks like this, based on your sample.