LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Notification problem (https://www.linuxquestions.org/questions/linux-software-2/notification-problem-883030/)

TalkingMarble 05-27-2011 08:19 AM

Notification problem
 
Hello,

Yesterday one of my co-workers pointed out that he not received any email-alerts from Nagios recently. I checked the particular config-file but nothing has changed. In case of an alert an email is sent to two groups (admin,sap) but only one group (admin) is receiving the alerts by email.

Code:

define host{
        use                    windows-server,host-pnp ; Inherit default values from a template
        host_name              xxxx                  ; The name we're giving to this host
        alias                  xxxx                  ; A longer name associated with the host
        contact_groups          sap,admin
        notification_period    daytime
        address                xx.xx.xx.x              ; IP address of the host
        }

In order to check if the problem was related to exchange 2003, i manually tested the sap emailaddress (mail -s test xxxx@xxx.xx). The sap emailaddress received the test mail so that made me think that exchange is not the problem.

I made a small adjusment to the notify-host-by-email command and forced a warning/error for that particular host to see the contents from variable $CONTACTEMAILS$.

Code:

# 'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "$CONTACTEMAIL$\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
        }

I noticed that the $CONTACTEMAILS$ variable was only containing the emailaddress from the admin group and was missing the emailaddress from the sap group when the mail command is executed.

Anybody an idea what is causing this problem and how i can solve it?

Any help will be appreciated.

JaapB

MensaWater 06-03-2011 12:10 PM

It works for me.

In my host definitions I have a space after the comma between groups whereas you don't. That probably isn't the problem but it can't hurt to try it. (e.g. "sap, admin").

Also the method used to notify users is actually defined in contacts.cfg. The groups are defined in contactgroups.cfg.

You should first verify the people you think are in the second group are actually in it in contactgroups.cfg. You should then examine those people in contacts.cfg and see what the specific entries are defined to use for notification. (For example in a recent alert I actually had 4 separate groups defined in the host entry. All 4 of those are in contactgroups.cfg. 3 of those groups contain only people from contacts.cfg that have host-notify-by-email whereas the other group contains only people from contacts.cfg that have host-notify-by-epager. In looking at history for that alert I see it used both host-notify-by-epager and host-notify-by-email (as appropriate for the users defined) so if I had looked only at what was happening with host-notify-by-email it would have appeared to me that the other users weren't getting notified even though they were.

TalkingMarble 06-06-2011 08:36 AM

I tried the space after the comma, but it makes no difference. I checked my contacts and contactgroups but everything seems in order.

MensaWater 06-06-2011 09:11 AM

So for each of the contacts in contacts.cfg defined in the groups in contactgroups.cfg you see the following?
Code:

host_notification_commands      notify-host-by-email
What file has your notify-host-by-email definition? Is it possible you're looking at the wrong one (e.g. do you have it defined in both commands.cfg and misccommands.cfg)?

TalkingMarble 06-07-2011 02:12 AM

After reading your first reply more carefully, i noticed service definitions in some of our config files did not contain a "contact_group" entry. This caused the service definition to inherance the "contact_group" from the service template which only contains the admins contact_group.

I don't know how this could have been working in the past, but after i made the required changes everything is working again.

Thanks for all your help MensaWater.

MensaWater 06-07-2011 02:18 PM

Glad you got it resolved. Can you go to Thread Tools at top of the page and mark this solved. It helps others when searching to find solved threads first.

As an FYI: host-notify-by... and service-notify-by... are separate entries in my setup so likely are in yours as well. Typically you would use the host-notify-by... for servers defined in hosts.cfg being completely unreachable whereas service-notify-by... are used for the individual services defined in services.cfg


All times are GMT -5. The time now is 09:13 AM.