Page 1 of 2

Adding a new contact group

Posted: Thu Jul 28, 2016 2:41 am
by amprantino
I am using a cumulative service definition for all hosts:

Code: Select all

define service{
        use                             generic-service
        host_name                       server1,servr2,server3.....,serverN
        service_description             REACHABLE
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              5
        normal_check_interval           10
        retry_check_interval            2
        contact_groups                  sys-admins
        notification_interval           240
        notification_period             24x7
        notification_options            c,r
        check_command                   check_ping!900.0,60%!1500.0,79%
}
Suddenly, a request arrived asking a new contact_group to be added for server2 and server5.
Is there a way to add it without creating a separate service definition for these two servers?

Re: Adding a new contact group

Posted: Thu Jul 28, 2016 2:14 pm
by ssax
My recommendation would be to define the contact groups on the host and not on the services so they would be inherited by the service for each host.

https://assets.nagios.com/downloads/nag ... tance.html

Like this:

Code: Select all

define service{
        use                             generic-service
        host_name                       server1,servr2,server3.....,serverN
        service_description             REACHABLE
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              5
        normal_check_interval           10
        retry_check_interval            2
        notification_interval           240
        notification_period             24x7
        notification_options            c,r
        check_command                   check_ping!900.0,60%!1500.0,79%
}

Code: Select all

define host {
        host_name                       server1
        use                             linux-server
        alias                           localhost
        contact_groups                  sys-admins
        address                         127.0.0.1
        register                        1
        }

define host {
        host_name                       server2
        use                             linux-server
        alias                           localhost
        contact_groups                  sys-admins,other-contact-group
        address                         127.0.0.1
        register                        1
        }

define host {
        host_name                       server5
        use                             linux-server
        alias                           localhost
        contact_groups                  sys-admins,other-contact-group
        address                         127.0.0.1
        register                        1
        }

Re: Adding a new contact group

Posted: Wed Oct 19, 2016 2:40 am
by amprantino
Probably I am doing something wrong:

host definition

Code: Select all

define host {
        host_name                       server1
        alias                           server1_alias
        address                         192.168.1.1
        parents                         myparent
        check_command                   check-host-alive
        max_check_attempts              2
        process_perf_data               0
        retain_nonstatus_information    1
        notification_interval           120
        notification_period             24x7
        notification_options            d,u,r
        contact_groups                  group1,group2
        contacts                        user1,user2
        }
service definition

Code: Select all

define service{
        use                             generic-service
        host_name                       server1
        service_description             Service1_definition
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           60
        retry_check_interval            1
        notification_interval           240
        notification_period             24x7
        notification_options            c,r
        check_command                   check_command
        }
When the service is down, only the contacts in "generic-service" will get the notification.
Am I missing something here?

Re: Adding a new contact group

Posted: Wed Oct 19, 2016 4:56 am
by amprantino
I had to remove "use generic-service" under service definition

Re: Adding a new contact group

Posted: Wed Oct 19, 2016 1:17 pm
by rkennedy
Just to make sure - were you able to get this resolved? It looks like the template may have been inheriting when you did not want it to.

Re: Adding a new contact group

Posted: Wed Oct 19, 2016 1:28 pm
by amprantino
Yes, exactly.

Also, can you please define if +contacgroup or -contactgrop are working inside a contact definition?

Re: Adding a new contact group

Posted: Wed Oct 19, 2016 4:09 pm
by avandemore
I'm not sure I understand your question. Does this document help? Object Definitions

If not, can you rephrase the question?

Re: Adding a new contact group

Posted: Thu Oct 20, 2016 1:40 am
by amprantino
According to this site http://www.techadre.com/content/nagios- ... nheritance
I can use
contactgroup_name +support
contactgroup_name !dev
etc

Are the above commands valid, as I can't find a relevant reference inside nagios documentation

Re: Adding a new contact group

Posted: Thu Oct 20, 2016 12:41 pm
by avandemore
This is our offical documentation for Object Inheritance

The url you linked to may or may not contain correct information. At the very least, its reported posting date is prior to any currently supported version.

Re: Adding a new contact group

Posted: Thu Oct 20, 2016 12:49 pm
by amprantino
Yes,
are those +/- supported in nagios?
Because I couldn't find in the official documentation