Page 1 of 1

Service Contact Inherited from Host Contact?

Posted: Tue Nov 08, 2016 11:32 am
by raulpe
Is there a way to make services associated with a host use the contacts defined with that host as opposed to or in addition to the ones defined in the service? In my situation I have multiple hosts, each with a POC (contact) that is responsible for them. I define the contact as part of the host definition so when changes occur with the host status they are notified (this works fine). I have defined services that are global to all hosts. An example could be something like temperature on a host. All hosts that can report temperature use the same service. I want to notify a temperature problem only the POC responsible for that host.

I am trying to avoid having to setup different service definitions just because they have different contacts. I was wondering if there was a host macro or something similar that can be referenced as the contact/contact group for the service. If so, how do I define that in Nagios XI CCM.

I am a subscription customer but decided to post this here as I think everyone could benefit from an answer.

Thanks.

Re: Service Contact Inherited from Host Contact?

Posted: Tue Nov 08, 2016 11:38 am
by avandemore
Please note there is a difference in methodology for alerting between Nagios Core and XI. That being said, the bulk of it works the same documented here:

Object Inheritance
Understanding Users and Contacts

A contact can adjust their own preferences on what type of notification to opt in for. Do this information answer your question?

Re: Service Contact Inherited from Host Contact?

Posted: Tue Nov 08, 2016 11:57 am
by raulpe
@avandemore, thank you for taking the time to answer my question.

I have setup the notification options for each of the contacts as needed. The problem is that I want different contacts to be notified for the same service alert depending on the host. The service does not seem to know that the hosts have different contacts. The service is only alerting the contacts defined in it's own service definition.

Maybe an example will clarify my issue:

Joe,Peter, and Admin are contacts with emails and properly defined notification preferences.
Host1 has contacts Joe and Admin. Host2 has contacts Peter and Admin. Whenever there is a host alert either Peter or Joe and the Admin are notified depending on which host failed the host check. So far so good.
ServiceA has contact Admin. ServiceA is associated with Host1 and Host2. When ServiceA alerts it only notifies Admin, not Peter or Joe. I want Peter or Joe be notified as well since they are the contacts for the host.

If I add Peter and Joe as contacts for ServiceA they will both receive notifications, no matter which host failed the service check.

Hopefully my example did not confuse things more. Thanks.

Re: Service Contact Inherited from Host Contact?

Posted: Tue Nov 08, 2016 12:40 pm
by rkennedy
If I add Peter and Joe as contacts for ServiceA they will both receive notifications, no matter which host failed the service check.
If I understand properly, you have a single service with MULTIPLE hosts assigned to it, is this correct?

If so, you'd need to create a service check specific to the host, that should have these 'special' contact rules applied. (they aren't really special, but just 'different' from the rest.)

Re: Service Contact Inherited from Host Contact?

Posted: Wed Nov 09, 2016 9:25 am
by raulpe
@rkennedy Thanks for your reply.

I feared that was going to be the only solution. The problem is that this situation happens for 14 services and about 12 different contacts. Creating service definitions specific to each contact will increase the number of service definitions from 14 to 168 and a change to one of them will require me to change multiple ones.

If that is the only solution then we can close this thread. Thanks everyone.

Re: Service Contact Inherited from Host Contact?

Posted: Wed Nov 09, 2016 3:07 pm
by avandemore
Services have a 1-1(many) relationship with users so I'm afraid this is the best course. You can define multiple services in text file(s), place them in the /usr/local/nagios/etc/import/, and run an apply configuration to import them en masse.