如何为 monit 中的同一服务向不同用户(类似的)设置不同周期失败的警报?
我已经尝试过像下面这样的配置。
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]
但是电子邮件地址行发生语法错误。
此人在第 1 个周期和第 3 个周期向两位用户发送了电子邮件
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]
这就是 Monit 处理警报语句的方式,请参阅 https://mmonit.com/monit/documentation/monit.html#Setting-an-alert-recipient
您可以使用全局“设置警报”语句或服务条目上下文中的“警报”语句来设置警报目标(电子邮件)。但您无法在测试环境中设置电子邮件地址。您可以使用“monit -v”来检查行为,以获取有关配置的一些 Monit 内部信息。
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
根据您的样本,看起来像这样。