Page 1 of 1

Simple Notifications Not Working

Posted: Fri Oct 12, 2012 11:13 am
by keithnickum
I am trying to test out configuration options to make sure nagios is working as I want it to, but I can't get notifications to work at all. I'm starting with just attempting to get notifications to log something (anything) to a file on the server, and that isn't working.

My nagios.cfg has enable_notifications set to 1. Under servers/example.com.cfg, I have this:

Code: Select all

define host{
    use                   linux-server
    host_name             example.com
}

define service {
    use                     generic-service
    host_name               example.com
    service_description     PING
    is_volatile             0
    check_period            24x7
    max_check_attempts      3
    normal_check_interval   5
    retry_check_interval    1
    check_command           check_ping!100.0,20%!500.0,60%
}

define service {
    use                     generic-service
    host_name               example.com
    service_description     SSH
    check_command           check_ssh
}

define service {
    use                     generic-service
    host_name               example.com
    service_description     HTTP
    check_command           check_http
}
I modified objects/commands.cfg to this (relevant portions):

Code: Select all

# 'notify-host-by-email' command definition
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"  >> /var/nagios/notify.log
  }

# 'notify-service-by-email' command definition
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" >> /var/nagios/notify.log
  }
I went through objects/template.cfg and made sure that notifications were enabled for all services and hosts, and left the configuration in example.com.cfg to pick up the template defaults...

Notably, I'm just trying get some relevant logging information sent to notify.log. I will stop nagios, copy out example.com.cfg and start nagios (to clear the 'server' from nagios), the stop nagios, copy example.com.cfg back in to the servers directory, and start nagios. The web interface shows that a check on example.com is pending, then shows that the check came back that example.com is down, but nothing is written into /var/nagios/notify.log. The nagios process is using nagios:nagios, and /var/nagios/notify.log is set to nagios:nagios. I haven't seen anything in the nagios.log that's relevant to why this is happening, and I've set nagios.debug to -1 and debug_verbosity to 2, and still am not seeing anything relevant.

Can anyone help me out here? What am I missing?

Re: Simple Notifications Not Working

Posted: Sun Oct 14, 2012 5:30 pm
by jsmurphy
It looks like you haven't defined a contact on anything? Without a contact it's never going to attempt to email or log or do anything as it will never execute the notify-by-x command.

Re: Simple Notifications Not Working

Posted: Wed Oct 17, 2012 8:34 am
by keithnickum
Well, it looks like there is some notification activity. I had some vacation time the last two days, came back today and saw that nagios is outputting information into the /var/nagios/notify.log file that I setup, although clearly trying to force it to log something right away isn't passing some filter. I'm switching the line back to sending an email, so I guess we'll just see how well that works. It looks like there were 228 Warnings for one server, 13 Warnings for localhost, and 9 Errors for example.com since Friday, so I think it's working.

For the contacts, I set up one user (nagiosadmin) in the admins group, and I'm using generic-service and linux-server templates from objects/templates.cfg, both of which are set up with 'contact_groups admins', so I think the contact information is good.

Is there a method to force nagios to send a test message to make sure I have everything configured correctly?

Re: Simple Notifications Not Working

Posted: Wed Oct 17, 2012 5:34 pm
by jsmurphy
There sure is :) ... if you click on any service, then look at the right hand control panel there is a link that says "Send custom service notification" this will force it to send a notification with whatever message you type in for that service.