以检查为基础,以邮件格式覆盖monit警报

我目前有两个监视每个主机我运行HTTPS:

check host www-example-https with address www.example.org if failed port 443 protocol https then alert check host www-example-certificate with address www.example.org every "25 10 * * *" if failed port 443 protocol https and certificate valid > 30 days then alert 

第一个警告我连接失败,每2分钟运行一次,而第二个提醒我说,一个证书的有效期至less30天,只有一天运行一次。

目前,这两项检查都会导致类似的警报消息,这意味着即将到期的证书看起来像HTTPS完全失败。 因此,我想重写每个警报的默认邮件选项。

我知道如果我想要更改所有的警报,我可以用set mail-format来做到这一点,但是如果我使用了一个if failed ... then alertif failed ... then alert我找不到单个警报的语法if failed ... then alert我可以在手册中找不到这个具体用例的例子。

对于上面定义的警报types,是否可以在每个警报基础上覆盖mail-format

这里的文档中有一个示例https://mmonit.com/monit/documentation/#CONFIGURATION-EXAMPLES

从个人testing来看,你无法避免“ 提醒a @ bc ”部分,所以为了适应你的需求,继续下去:

 check host www-example-https with address www.example.org if failed port 443 protocol https then alert alert [email protected] with mail-format { # use local format subject: https is down on www.example.org message: https is down on www.example.org with port 443 Yours sincerely, monit } check host www-example-certificate with address www.example.org every "25 10 * * *" if failed port 443 protocol https and certificate valid > 30 days then alert alert [email protected] with mail-format { # use local format subject: https certificate expiration for www.example.org message: https is certificate is less than 30 days on www.example.org with port 443 $SERVICE $EVENT at $DATE Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION. Yours Pal, MoMoMonit } 

另外,如果主机是“失败”,证书检查将不会执行。

在任何地方使用“ 设置邮件格式 ”, 更改所有通知