从Nagios 3.5.0(在Ubuntu上)的自动通知似乎没有工作,并给出的错误是“没有联系人被发现通知的目的,没有通知发出”。 下面的代码可以在debugging日志中find:
[1370347017.047457] [032.0] [pid=30297] ** Service Notification Attempt ** Host: 'nbsrvcomp-11', Service: 'Number open file descriptors', Type: 0, Options: 0, Current State: 1, Last Notification: Thu Jan 1 01:00:00 1970 [1370347017.047520] [032.0] [pid=30297] Notification viability test passed. [1370347017.047530] [032.1] [pid=30297] Current notification number: 1 (incremented) [1370347017.047539] [032.1] [pid=30297] Service notification will NOT be escalated. [1370347017.047545] [032.1] [pid=30297] Adding normal contacts for service to notification list. [1370347017.047555] [032.0] [pid=30297] No contacts were found for notification purposes. No notification was sent out.
检查configuration我看不到任何问题:
root@nbsrvnagi-01v:/etc/apache2# grep -i enable_notifications /usr/local/nagios/etc/nagios.cfg enable_notifications=1 root@nbsrvnagi-01v:/etc/apache2# grep cfg /usr/local/nagios/etc/nagios.cfg cfg_file=/etc/nagiosql/timeperiods.cfg cfg_file=/etc/nagiosql/commands.cfg cfg_file=/etc/nagiosql/contacts.cfg cfg_file=/etc/nagiosql/contactgroups.cfg cfg_file=/etc/nagiosql/contacttemplates.cfg cfg_dir=/etc/nagiosql/hosts cfg_file=/etc/nagiosql/hosttemplates.cfg cfg_file=/etc/nagiosql/hostgroups.cfg cfg_file=/etc/nagiosql/hostextinfo.cfg cfg_file=/etc/nagiosql/hostescalations.cfg cfg_file=/etc/nagiosql/hostdependencies.cfg cfg_dir=/etc/nagiosql/services cfg_file=/etc/nagiosql/servicetemplates.cfg cfg_file=/etc/nagiosql/servicegroups.cfg cfg_file=/etc/nagiosql/serviceextinfo.cfg cfg_file=/etc/nagiosql/serviceescalations.cfg cfg_file=/etc/nagiosql/servicedependencies.cfg root@nbsrvnagi-01v:/etc/apache2# cat /etc/nagiosql/contactgroups.cfg define contactgroup { contactgroup_name admins alias Nagios Administrators members chlewis register 1 } root@nbsrvnagi-01v:/etc/apache2# cat /etc/nagiosql/contacts.cfg define contact { contact_name chlewis alias Chris Lewis contactgroups admins host_notifications_enabled 1 service_notifications_enabled 1 host_notification_period 24x7 service_notification_period 24x7 host_notification_options d,u,r,f,s,n service_notification_options w,u,c,r,f,s,n host_notification_commands notify-host-by-email service_notification_commands notify-service-by-email can_submit_commands 1 email <removed> register 1 } root@nbsrvnagi-01v:/etc/apache2# cat /etc/nagiosql/services/check_open_fds.cfg define service { #NAGIOSQL_CONFIG_NAME check_open_fds hostgroup_name * service_description Number open file descriptors display_name Number open file descriptors check_command check_nrpe!check_oepn_fds max_check_attempts 5 check_interval 5 retry_interval 3 check_period 24x7 event_handler notify-service-by-email notification_interval 120 notification_period 24x7 notification_options w,u,c,r,f,s contact_groups admins register 1 } root@nbsrvnagi-01v:/etc/apache2# cat /etc/nagiosql/servicetemplates.cfg define service { name generic-service is_volatile 0 max_check_attempts 4 check_interval 5 retry_interval 1 active_checks_enabled 1 passive_checks_enabled 1 check_period 24x7 parallelize_check 1 obsess_over_service 1 check_freshness 0 event_handler notify-service-by-email event_handler_enabled 1 flap_detection_enabled 1 process_perf_data 1 retain_status_information 1 retain_nonstatus_information 1 notification_interval 0 notification_period 24x7 notification_options w,u,c,r notifications_enabled 1 contact_groups admins failure_prediction_enabled 1 register 0 } root@nbsrvnagi-01v:/etc/apache2# cat /etc/nagiosql/commands.cfg define command { command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ register 1 } define command { command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ register 1 }
一个奇怪的是,自定义通知工作:
[1370347216.906200] [032.0] [pid=30297] ** Service Notification Attempt ** Host: 'nbsrvcomp-11', Service: 'Number open file descriptors', Type: 99, Options: 0, Current State: 1, Last Notification: Thu Jan 1 01:00:00 1970 [1370347216.906295] [032.0] [pid=30297] Notification viability test passed. [1370347216.906304] [032.1] [pid=30297] Current notification number: 0 (unchanged) [1370347216.906317] [032.1] [pid=30297] Service notification will NOT be escalated. [1370347216.906329] [032.1] [pid=30297] Adding normal contacts for service to notification list.
任何帮助都感激不尽。
问题是由于您已经定义了所有选项的联系人:
host_notification_options d,u,r,f,s,n service_notification_options w,u,c,r,f,s,n
其中,是选项n (无)。 所以,你没有收到任何通知。 从主机和服务通知中删除选项n联系人和问题已解决。
我认为contactgroups必须是contact_groups