-1

I can't get notifications in my emails from Nagios:

Step 1.

First, I have defined my hosts in: /etc/nagios3/conf.d/ One of hosts that I've defined is: server2.cfg

define host {
        host_name               serveri2
        alias                   serveri2
        address                 54.243.9.241
        max_check_attempts      3
        check_period            24x7
        check_command           check-host-alive
        contacts                root
        notification_interval   60
        notification_period     24x7
}

Step 2.

I have added 2 contacts in this file: contacts_nagios2.cfg

define contact{
    contact_name                    root
    alias                           Root
    service_notification_period     24x7
    host_notification_period        24x7
    service_notification_options    w,u,c,r
    host_notification_options       d,r
    service_notification_commands   notify-service-by-email
    host_notification_commands      notify-host-by-email
    email                           myemail1@example.com
}

define contact{
    contact_name                    gex
    alias                           Gex
    service_notification_period     24x7
    host_notification_period        24x7
    service_notification_options    w,u,c,r
    host_notification_options       d,r
    service_notification_commands   notify-service-by-email
    host_notification_commands      notify-host-by-email
    email                           myemail2@example.com
}

Step 3

then below I've defined users in contact groups:

define contactgroup{
    contactgroup_name       admins
    alias                   Nagios Administrators
    members                 root, gex
}
  • What mail server are you running on your nagios host? How do you have it configured? Have you checked the mail server logs for errors? Have you performed all the common steps to make sure that it isn't being blocked as SPAM? – Zoredache Feb 7 '14 at 21:17
  • @Zoredache I have tried with 1 email, this option worked. namely is not problem at mail server. but contact groups don't work. – Gex Feb 7 '14 at 21:19
  • Not sure what is your problem (is sending email to a single contact works ? or only contact groups does not work ?) but maybe you should set contact_groups admins in your host definition, to send an email alert to all members of admins groups ? – krisFR Feb 7 '14 at 21:27
3

I think the problem is that gex is not a contact for the host serveri2:

define host {
        host_name               serveri2
        alias                   serveri2
        address                 54.243.9.241
        max_check_attempts      3
        check_period            24x7
        check_command           check-host-alive
        contacts                root
        notification_interval   60
        notification_period     24x7
}

Add gex to the contacts line, or change that line to

        contact_groups          admins

and see if that resolves your issue.

1

To send an email to both root and gex contact, i would suggest to define the admins group as a contact group in your host definition, as they are both members of this group :

Replace contacts root by contact_groups admins in your host definition :

define host {
        host_name               serveri2
        alias                   serveri2
        address                 54.243.9.241
        max_check_attempts      3
        check_period            24x7
        check_command           check-host-alive
        contact_groups          admins
        notification_interval   60
        notification_period     24x7
}

The fact is that groups are easier to manage than single contacts.

In some quite big companies i've seen an interesting approach that consists in sending a single email to a single email address, that is in fact an address list.

So, then, mail distribution is mainly at mail server side, and contacts management is mainly a mail server admin task :

  • a single email to network.team@dom.com : delivers an email to all members of this list
  • a single email to it.team@dom.com : delivers an email to all members of this list
  • a single email to dba.team@dom.com : delivers an email to all members of this list
  • and so on...

Because the way Nagios works, it will send an individual email to all members of a groups. Means that if your group contains 10+ contacts, Nagios will send 10+ emails !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.