Confguring mutiple contacts in contact.cfg

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Confguring mutiple contacts in contact.cfg

Post by jdalrymple »

I see multiple notifications for 2 services:

Code: Select all

contact          host               service
nagiosadmin      PortalWeb1         CPU Load
nagiosadmin      recruiter-db       C:\ Drive Space
This tells me that those 2 service definitions have either or both of the following lines:

Code: Select all

     contacts                         nagiosadmin
     contact_groups                   admins
Since no other services have notifications associated I wouldn't expect any other contacts to be notified. Can you confirm or deny any of the above?
joshtate2001
Posts: 29
Joined: Wed Apr 08, 2015 1:55 pm

Re: Confguring mutiple contacts in contact.cfg

Post by joshtate2001 »

I do not think you are getting the issue.
Yes I have multiple host that use one or more contact groups. This should not be a problem.

Again, the problem is simply that when using contact groups; if more than one contact is specified, it only send to the first contact in the contact group.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Confguring mutiple contacts in contact.cfg

Post by jdalrymple »

joshtate2001 wrote:I do not think you are getting the issue....if more than one contact is specified, it only send to the first contact in the contact group.
I get it - I promise.

We're going through the troubleshooting process. I started by verifying your contact configuration - it looks good. The next step is to identify whether Nagios is actually issuing the notification command or not, and if so to whom. Right now I see it issuing the notification command to only nagiosadmin in log you shared for 2 separate services. So right now from my point of view (the guy simply trying to help you) there don't appear to be any notifications raised that should have went to any of your specified contactgroups. nagiosadmin is actually only in 1 contactgroup, and it isn't one of your contactgroups with multiple contacts.

Do you in fact have any services with your other contactgroups defined. If so can you submit a custom notification for that service then either share with us your nagios.log again, or preferably try `grep NOTIFICATION nagios.log` - that should have worked for you before and I'm not sure why it didn't.
joshtate2001
Posts: 29
Joined: Wed Apr 08, 2015 1:55 pm

Re: Confguring mutiple contacts in contact.cfg

Post by joshtate2001 »

The notifications in the log I sent you are going to "nagiosadmin" and "PortalWeb1"
The notifications in the log (according to what I see) ARE going to the contact and contact group.
The problem is when it hits the contact group, it chooses the first contact in the contact group.

From the log I have:
[1438575044] SERVICE NOTIFICATION: nagiosadmin;PortalWeb1;CPU Load;CRITICAL;notify-service-by-email;CPU Load 99% (5 min average)
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Confguring mutiple contacts in contact.cfg

Post by jdalrymple »

I understand your confusion. You misunderstand the log format. Please note that you don't actually have any contactgroups named "PortalWeb1," you're probably thinking of the contactgroup you have named "portaladmin."

As I mentioned earlier, when you have a NOTIFICATION log entry, you will have repeated entries for each and every contact that gets notified based upon an alert. In your log:

Code: Select all

[1438574804] SERVICE ALERT: PortalWeb1;CPU Load;CRITICAL;SOFT;1;CPU Load 99% (5 min average)
[1438574924] SERVICE ALERT: PortalWeb1;CPU Load;CRITICAL;SOFT;2;CPU Load 99% (5 min average)
[1438575044] SERVICE ALERT: PortalWeb1;CPU Load;CRITICAL;HARD;3;CPU Load 99% (5 min average)
[1438575044] SERVICE NOTIFICATION: nagiosadmin;PortalWeb1;CPU Load;CRITICAL;notify-service-by-email;CPU Load 99% (5 min average)
[1438575644] SERVICE ALERT: PortalWeb1;CPU Load;OK;HARD;3;CPU Load 0% (5 min average)
[1438575644] SERVICE NOTIFICATION: nagiosadmin;PortalWeb1;CPU Load;OK;notify-service-by-email;CPU Load 0% (5 min average)
Translates to:

ALERT 1 SOFT CRITICAL
ALERT 2 SOFT CRITICAL
ALERT 3 transition to HARD CRITICAL (raise notification)
NOTIFICATION to nagiosadmin CRITICAL
ALERT 1 HARD OK
NOTIFICATION to nagiosadmin OK

What you would like to see it sounds like is something more like this:

Code: Select all

[1438574804] SERVICE ALERT: PortalWeb1;CPU Load;CRITICAL;SOFT;1;CPU Load 99% (5 min average)
[1438574924] SERVICE ALERT: PortalWeb1;CPU Load;CRITICAL;SOFT;2;CPU Load 99% (5 min average)
[1438575044] SERVICE ALERT: PortalWeb1;CPU Load;CRITICAL;HARD;3;CPU Load 99% (5 min average)
[1438575044] SERVICE NOTIFICATION: rcarter;PortalWeb1;CPU Load;CRITICAL;notify-service-by-email;CPU Load 99% (5 min average)
[1438575044] SERVICE NOTIFICATION: jwells;PortalWeb1;CPU Load;CRITICAL;notify-service-by-email;CPU Load 99% (5 min average)
[1438575044] SERVICE NOTIFICATION: joshtate2001;PortalWeb1;CPU Load;CRITICAL;notify-service-by-email;CPU Load 99% (5 min average)
[1438575044] SERVICE NOTIFICATION: jtate;PortalWeb1;CPU Load;CRITICAL;notify-service-by-email;CPU Load 99% (5 min average)
[1438575644] SERVICE ALERT: PortalWeb1;CPU Load;OK;HARD;3;CPU Load 0% (5 min average)
[1438575644] SERVICE NOTIFICATION: rcarter;PortalWeb1;CPU Load;OK;notify-service-by-email;CPU Load 0% (5 min average)
[1438575644] SERVICE NOTIFICATION: jwells;PortalWeb1;CPU Load;OK;notify-service-by-email;CPU Load 0% (5 min average)
[1438575644] SERVICE NOTIFICATION: joshtate2001;PortalWeb1;CPU Load;OK;notify-service-by-email;CPU Load 0% (5 min average)
[1438575644] SERVICE NOTIFICATION: jtate;PortalWeb1;CPU Load;OK;notify-service-by-email;CPU Load 0% (5 min average)
Understand?

Now that I've hopefully clarified how the logging works can you post your service definition for CPU Load on host PortalWeb1? Also if it has a "use" line indicating it has upstream templates, please post those as well. I think this is all a simple misconfiguration in your host and/or service. As I mentioned, there is nothing wrong with your contacts' and contactgroups' definitions, and your log makes it appear that the services just aren't configured properly to alert the contactgroups you're trying to hit.
joshtate2001
Posts: 29
Joined: Wed Apr 08, 2015 1:55 pm

Re: Confguring mutiple contacts in contact.cfg

Post by joshtate2001 »

Attached is my portal.cfg, which has the portalweb1 host.
Not sure what you want me to post with LINE.
Attachments
portal.cfg
(5.1 KiB) Downloaded 213 times
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Confguring mutiple contacts in contact.cfg

Post by jdalrymple »

Here is the problem:

Code: Select all

define service{
	use			generic-service
	host_name		PortalApp1,PortalSQL1,PortalWeb1
	service_description	CPU Load
	check_command		check_nt!CPULOAD!-l 5,80,90
	}
I did notice that you have them defined in your host:

Code: Select all

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       PortalWeb1       ; The name we're giving to this host
		hostgroups		Portal-PROD-servers
        alias           PortalWeb1  ; A longer name associated with the host
        address         152.38.30.110     ; IP address of the host
        contact_groups	portaladmin
		notifications_enabled	1
		}
That is in fact adequate in some cases, my guess is that in your case generic-service template has the contactgroup admins defined though which negates the implied inheritance. You can either explicitly define the contact_groups in your service definition or remove the contact_groups object from all template definitions upstream, starting with generic-service.
joshtate2001
Posts: 29
Joined: Wed Apr 08, 2015 1:55 pm

Re: Confguring mutiple contacts in contact.cfg

Post by joshtate2001 »

Umm...

My contact groups are working, except it is sending to only the first contact listed in the contact groups. Why?
Also, according to documentation I should not have to specify contacts or contact groups on each service in the service definitions.
You are suppose to be able to define the contact groups on the host definitions.

Like, I stated. The contact groups themselves are working.
The problem is if there is more than one contact listed for that group, it sends it to the first one listed. Why?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Confguring mutiple contacts in contact.cfg

Post by jdalrymple »

I have stated the problem for you:
jdalrymple wrote:That is in fact adequate in some cases, my guess is that in your case generic-service template has the contactgroup admins defined though which negates the implied inheritance.
Object Inheritance wrote:The following table lists the object variables that will be implicitly inherited from related objects if you don't explicitly specify their value in your object definition or inherit them from a template.
I have also explained how to fix it:
jdalrymple wrote:You can either explicitly define the contact_groups in your service definition or remove the contact_groups object from all template definitions upstream, starting with generic-service.
Also - I'm having trouble seeing this:
joshtate2001 wrote:The problem is if there is more than one contact listed for that group, it sends it to the first one listed. Why?
I want to answer your question, except from the nagios.log snippet you sent I don't see the behavior you're describing. I only see nagiosadmin (not part of any contactgroup with multiple members) being notified.
joshtate2001
Posts: 29
Joined: Wed Apr 08, 2015 1:55 pm

Re: Confguring mutiple contacts in contact.cfg

Post by joshtate2001 »

I have it working correctly mow. I ended up going to the templates.cfg and adding a service definition for all my host group definitions.
Each service definition has the contact group or groups that need to be notified.
I am now getting emails on both of my email accounts as desired.
This topic is resolved. Thanks for your help!
Locked