Can't get automatic notifications working

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
chrislewis28
Posts: 11
Joined: Tue Jun 04, 2013 6:49 am

Can't get automatic notifications working

Post by chrislewis28 »

Hi,

The automated notifications from Nagios 3.5.0 (on Ubuntu) don't seem to work and the error given is "No contacts were found for notification purposes. No notification was sent out". The below can be found in the debug log:

Code: Select all

[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.
Checking the config I can't see any problems:

Code: Select all

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
}

Code: Select all

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
}
One strange this is that custom notifications work:

Code: Select all

[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.
[1370347237.208414] [032.0] [pid=30297] 1 contacts were notified.
Any help will be much appreciated.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Can't get automatic notifications working

Post by slansing »

We will need to see the host and service definition for the object the nagios log said can't find a contact. It is likely the contacts line has nothing added to it.
chrislewis28
Posts: 11
Joined: Tue Jun 04, 2013 6:49 am

Re: Can't get automatic notifications working

Post by chrislewis28 »

Fixed it, in the contacts.cfg for the user the notifications were "w,c,u,f,r,n"

The n was stopping all notifications! I used nagiosql to configure and just ticked all options without really reading!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Can't get automatic notifications working

Post by abrist »

chrislewis28 wrote:The n was stopping all notifications! I used nagiosql to configure and just ticked all options without really reading!
No problem, even we fail the literacy check once in a while! Cheers.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked