我无法弄清楚,但由于某种原因,Nagios并没有向我发送关于我监视的某些服务的警报,我想知道是否有人可以帮我一下。
这是服务
定义服务{ hostgroup_name nrpe-disk service_description磁盘 使用警报,检查 check_command check_nrpe1!check_disk 注册1 }
这是我的命令
定义命令{ command_name check_nrpe1 command_line $ USER1 $ / check_nrpe -H $ HOSTADDRESS $ -c $ ARG1 $ }
这里是服务模板
定义服务{ 名称报警 notification_interval 0 notification_period 247 notification_options w,u,r,c,f,s notifications_enabled 1 contact_groups工作人员 寄存器0 }
定义命令{ command_name通知主机的电子邮件 command_line / usr / bin / printf“%b”“***** Nagios ***** \ n \ n通知types:$ NOTIFICATIONTYPE $ \ n主机:$ HOSTNAME $ \ n状态:$ HOSTSTATE $ \ n地址:$ HOSTADDRESS $ \ n信息:$ HOSTOUTPUT $ \ n \ ndate/时间:$ LONGDATETIME $ \ n“| / usr / bin / mail -s“** $ NOTIFICATIONTYPE $主机警报:$ HOSTNAME $是$ HOSTSTATE $ **”$ CONTACTEMAIL $ } 定义命令{ command_name通知主机的页面 command_line / usr / bin / printf“%b”“通知types:$ NOTIFICATIONTYPE $ \ n主机:$ HOSTNAME $ \ n状态:$ HOSTSTATE $ \ n地址:$ HOSTADDRESS $ \ n信息:$ HOSTOUTPUT $” / usr / bin / mail $ CONTACTPAGER $ } 定义命令{ command_name通知服务的电子邮件 command_line / usr / bin / printf“%b”“***** Nagios ***** \ n \ n通知types:$ NOTIFICATIONTYPE $ \ n \ n服务:$ SERVICEDESC $ \ n主机:$ HOSTALIAS $ \ n地址:$ HOSTADDRESS $ \ nState:$ SERVICESTATE $ \ n \ ndate/时间:$ LONGDATETIME $ \ n \ n其他信息:\ n \ n $ SERVICEOUTPUT $“| / usr / bin / mail -s“** $ NOTIFICATIONTYPE $服务提示:$ HOSTALIAS $ / $ SERVICEDESC $是$ SERVICESTATE $ **”$ CONTACTEMAIL $ } 定义命令{ command_name通知服务的页面 command_line / usr / bin / printf“%b”“通知types:$ NOTIFICATIONTYPE $ \ n \ n服务:$ SERVICEDESC $ \ n主机:$ HOSTALIAS $ \ n地址:$ HOSTADDRESS $ \ nState:$ SERVICESTATE $ \ n \ n其他信息: \ n \ n $ SERVICEOUTPUT $“| / usr / bin / mail $ CONTACTPAGER $ }
定义联系人组{ contactgroup_name工作人员 别名XXXXXXXX 成员XXXXXXXX XXXXXXXX }
定义联系人{ 联系人姓名XXXXXXX XXXXXX 别名XXXXXXXXX host_notifications_enabled 1 service_notifications_enabled 1 host_notification_period 247 service_notification_period 247 host_notification_options d,u,r,f,s service_notification_options w,u,c,r,f,s host_notification_commands notify-host-by-email,notify-host-by-pager service_notification_commands notify-service-by-email,notify-service-by-pager 电子邮件[email protected] 寻呼机[email protected] }
我没有看到你的问题或任何答案中提到,但你检查了nagios.cfg
文件的enable_notifications设置? 它被设置为0还是1 ?
这也只是在给定的服务通知上发生,还是影响所有通知? 如果是这样,我会怀疑nagios.cfg文件中的enable_notifications设置为0。 如果是这样,请尝试将其更改为1并重新启动Nagios。
nagiosdebugging日志帮助我诊断一个类似的问题。 这是接近我的nagios.cfg的结尾
debug_level=32 debug_file=/var/log/nagios3/nagios.debug debug_verbosity=2
重新启动nagios,然后nagios.debug
文件; 它会告诉你像这样的东西:
[1416254305.106042] [032.0] [pid=928] ** Service Notification Attempt ** Host: 'myhost', Service: 'myservice', Type: 0, Options: 0, Current State: 2, Last Notification: Wed Dec 31 19:00:00 1969 [1416254305.106106] [032.0] [pid=928] Notification viability test passed. [1416254305.106114] [032.1] [pid=928] Current notification number: 1 (incremented) [1416254305.106120] [032.2] [pid=928] Creating list of contacts to be notified. [1416254305.106137] [032.1] [pid=928] Service notification will NOT be escalated. [1416254305.106174] [032.1] [pid=928] Adding normal contacts for service to notification list. [1416254305.106185] [032.2] [pid=928] Adding contact 'mycontact' to notification list. [1416254305.106219] [032.2] [pid=928] ** Attempting to notifying contact 'mycontact'... [1416254305.106449] [032.2] [pid=928] ** Checking service notification viability for contact 'mycontact'... [1416254305.106463] [032.2] [pid=928] We shouldn't notify this contact about CRITICAL service states. [1416254305.106474] [032.0] [pid=928] No contacts were notified. Next possible notification time: Wed Dec 31 19:00:00 1969 [1416254305.106481] [032.0] [pid=928] 0 contacts were notified.
在我的情况下,我有一个不好的联系service_notification_options
,这阻止了最初的通知出去,这阻止了我所有的升级(如果我们从未发送通知0,我们不能通知1)
我的第一步是尝试直接定义所有参数,而不是依赖于inheritance。 如果可以的话,也要避免组织。 这至less给你一个干净的起点去debugging。
define service { host_name XXXXXXX service_description disk notification_interval 0 notification_period 247 notifications_enabled 1 contacts XXXXXXX check_command check_nrpe1!check_disk }
您可能还想尝试将notification_interval切换为其他内容,甚至将其忽略(默认为60)。 直到你得到它的工作。
你的命令configuration文件中是否有“通过电子邮件通知”部分? 这里是我的相关部分:
定义命令{command_name send-email command_line / usr / bin / printf“%b”“***** Nagios ***** \ n \ n通知types:$ NOTIFICATIONTYPE $ \ n \ n服务:$ SERVICEDESC $ \ n主机: $ HOSTALIAS $ \ n地址:$ HOSTADDRESS $ \ nState:$ SERVICESTATE $ \ n \ ndate/时间:$ LONGDATETIME $ \ n \ n其他信息:\ n $ SERVICEOUTPUT $“ / bin / mail -s“** $ NOTIFICATIONTYPE $ alert – $ HOSTALIAS $ / $ SERVICEDESC $是$ SERVICESTATE $ **”$ CONTACTEMAIL $}
一般你的系统可以发送邮件吗? 你可以使用“邮件[email protected]”,然后键入一些文本,一个空行,最后Ctrl-D发送?
改变
register 0
至
register 1
在你的“警报”服务可能会有所帮助。
服务模板在哪里检查 ? 由于您正在使用模板报警和检查。 我想检查覆盖报警 …
define service { hostgroup_name nrpe-disk service_description disk use alarm,check check_command check_nrpe1!check_disk register 1 }
也许notification_failure_criteria可以帮助你
你真的有一个叫247或247的notification_period吗?
你从你的命令得到正确的反馈(所以应该有一个警报?)? 你在命令行上testing了这个命令(就像你的nagios用户一样)?