Nagios发送每日警报历史作为电子邮件

我知道我们可以使用nagios插件通过电子邮件发送任何types的严重警报的电子邮件。 现在我想要发送一封电子邮件作为每天最后一天的重要提醒的报告。 有人可以帮我解决这个问题。

现在我想要发送一封电子邮件作为每天最后一天的重要提醒的报告。

编辑nagios.cfg将旋转方法更改为每天:

 # LOG ROTATION METHOD # This is the log rotation method that Nagios should use to rotate # the main log file. Values are as follows.. # n = None - don't rotate the log # h = Hourly rotation (top of the hour) # d = Daily rotation (midnight every day) # w = Weekly rotation (midnight on Saturday evening) # m = Monthly rotation (midnight last day of month) log_rotation_method=d 

然后parsingCRITICAL警报的nagios.log ,如下所示:

 awk '/SERVICE ALERT: .*;CRITICAL;HARD/ { print $0 }' nagios.log | \ perl -pe 's/(\d+)/localtime($1)/e' | \ mail -s "Nagios daily report $(date +%F)" <your_email>@domain.com 

如果需要,可以在每天结束时运行上述命令。

您可以查看http://<nagios-server>/cgi-bin/icinga/summary.cgi并select您想要每天查看的报告。 摆弄参数后,抓取生成的报告的URL。

现在通过cron做类似如下的事情:

  • 从该url抓取报告
  • 如果你想,预处理和重新排列你刚刚拉下的HTML
  • 通过电子邮件发送

为了调用shell中的cgi,你应该考虑阅读这些提示(他们正在瞄准Icinga 1.x,所以一些cgi参数可能不适用于Nagios)。

http://docs.icinga.org/latest/en/cgiparams.html

http://docs.icinga.org/latest/en/cgicmd.html