pra*_*tri 2 linux monitoring nagios
我知道我们可以使用 nagios 插件通过电子邮件通知来发送任何类型的严重警报的电子邮件。现在,我希望每天发送一封电子邮件作为过去一天的关键警报的报告。有人可以帮我解决这个问题。
现在,我希望每天发送一封电子邮件作为过去一天的关键警报的报告。
编辑将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
Run Code Online (Sandbox Code Playgroud)
然后解析nagios.log
CRITICAL 警报,如下所示:
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
Run Code Online (Sandbox Code Playgroud)
如果需要,请在一天结束时将上述命令作为每日 cron 作业运行。
归档时间: |
|
查看次数: |
4348 次 |
最近记录: |