如果没有问题,我需要configurationNagios发送一个通知,说明一切顺利。
这种设置是存在还是有插件?
我使用以下设置每天发送一次电子邮件。 这让我知道,我的Nagios服务器,电子邮件系统和Nagiosconfiguration一切正常。
# nagios/objects/localhost.cfg .... # Send a message once per day to make sure nagios is working ok define service{ use local-service host_name localhost service_description Nagios is OK check_command check_all_is_well check_period morning ; this is a custom period normal_check_interval 60 ; setting this to an hour and making the check_period ; interval 59 minutes long each day ensures it only ; happens once per day in a specific window }
并在你timeperiodsconfiguration文件:
# nagios/objects/timeperiods.cfg .... define timeperiod{ timeperiod_name morning alias First thing in the am monday 06:00-6:59 tuesday 06:00-6:59 wednesday 06:00-6:59 thursday 06:00-6:59 friday 06:00-6:59 saturday 06:00-6:59 sunday 06:00-6:59 }
而check_all_is_ok命令是一个简单的sendmail包装器:
# check_all_is_ok #!/bin/bash echo "All is well from Nagio on `hostname`" \ | /etc/nagios/sendmail -s "Nagios on PIP is OK" <your email address> echo "OK: nagios is ok on `hostname`"; exit 0
它不检查在过去的24小时内没有问题,但是如果你需要的话,你可以添加一些grea-ping的日志作为guanta的build议。 您也可以通过将normal_check_interval设置为1440(24小时)来完成一天一次的要求,但是我希望每天在特定的窗口中运行该检查。
如果您configuration了每日日志轮转( log_rotation_method=d ),则可以编写一个脚本来计算nagios.log中警报的nagios.log ,如下所示:
[ `grep -c ALERT var/nagios.log` -eq 0 ] && echo "Everything is OK!" | mail -s "Nagios daily report" your@email
把它放到一个cron工作上,在你睡觉之前,在一天结束的时候运行。
如果不这样做,请参阅此主题根据date进行过滤。
这个解决scheme很大程度上取决于您何时实际发送通知:
根据情况,你应该决定一个解决scheme。 永远记住:做最简单的事情,可能工作。
这有点晚,但对于其他寻找解决scheme的人来说,使用livestatus broker模块还是一个简单的方法。
设置livestatus使用unix套接字(Shinken,默认情况下,只有使用tcp端口进行设置,可以像在此页面上的configuration一样添加套接字),并且可以使用例如python脚本直接进行轮询。