using contacts causing double email alert

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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: using contacts causing double email alert

Post by Box293 »

hata_ph wrote:[1411110576] SERVICE NOTIFICATION: itnetworksupport;SRMSHOST08A;C Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - C:\ Label: Serial Number 30ae4373 at 82% with 5,220 of 30,482 MB free
So I'm looking through your configs from nagios3.zip

The service "C Drive" for the host "SRMSHOST08A"

define service{
use generic-service-cim
host_name SRMSHOST08A
service_description C Drive
check_command check_snmp_disk!public!C!70%!80%
#notifications_enabled 1
}

USES the template generic-service-cim

define service{
name generic-service-cim
use generic-service-template
#contacts itcim
contact_groups cim-admins
}

It has the contact_groups cim-admins

define contactgroup{
contactgroup_name cim-admins
alias CIM Admins
members itcim
}

It has the members itcim

define contact{
contact_name itcim
alias IT CIM
use contact-template
email itcim@xxx.com,itnetworksupport@xxx.com
#email itnetworksupport@xxx.com
}

It has TWO email addresses specified:
email itcim@xxx.com,itnetworksupport@xxx.com


I would be going and correcting all of your contact items that have more than one email address.

As per the core documentation:
http://nagios.sourceforge.net/docs/3_0/ ... ml#contact
email: This directive is used to define an email address for the contact. Depending on how you configure your notification commands, it can be used to send out an alert email to the contact. Under the right circumstances, the $CONTACTEMAIL$ macro will contain this value.

I think the important words here are "an" and "the" meaning ONE email address per contact.
.... used to define an email address for the contact ....


Once you start configuring Nagios in a manner that it is not coded for, unexpected results can occur.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

Thanks Box293 for your explanation.
I put multiple email into contacts instead of contact_groups is because I want to receive emails with the respected email groups in 1 alert. Using contact_groups with multiple members will result in seperate emails...
If confirm the contacts code is not design for multiple email address, i would like to know is there possible way to put multipls email address in 1 single alert?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: using contacts causing double email alert

Post by Box293 »

hata_ph wrote: i would like to know is there possible way to put multipls email address in 1 single alert?
I don't believe there is. When core is at the stage of sending notifications, it sends individual notifications to each contact.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

Ok. So it is confirm my problem is due to multiple email address in single contacts?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: using contacts causing double email alert

Post by Box293 »

That would appear to be the case.

Once you start configuring Nagios in a manner that it is not coded for, unexpected results can occur.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

Box293,

On your suggestion I try to put single email address to my contacts but the problem is still there. Any idea?
I have attached few nagios config files that I have modify, there rest are the same from my pervious attachment.

Code: Select all

[1412037382] SERVICE NOTIFICATION: itnetworksupport;6800SRETDB;F Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - F:\ Label:New Volume  Serial Number 46939174 at 96% with 10,170 of 286,081 MB free
[1412037382] SERVICE NOTIFICATION: itdba;6800SRETDB;F Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - F:\ Label:New Volume  Serial Number 46939174 at 96% with 10,170 of 286,081 MB free
[1412037382] SERVICE ALERT: SIT_LOTDISPATCH;Physical Memory;WARNING;SOFT;3;SNMP WARNING - Physical Memory at 83% with 334 of 2,047 MB free
mail.log show 2 email send to itnetworksupport@xxx.com because I use same email address in my nagios contacts list for testing.

Code: Select all

Sep 30 08:36:22 SIT-NAGIOS postfix/qmgr[989]: 21CA8600B3: from=<nagios@SIT-NAGIOS>, size=629, nrcpt=1 (queue active)
Sep 30 08:36:22 SIT-NAGIOS postfix/smtp[25563]: 16B2760094: to=<itnetworksupport@xxx.com>, relay=sit-smtp01.xxx.com[10.16.0.142]:25, delay=0.31, delays=0.03/0.01/0/0.26, dsn=2.6.0, status=sent (250 2.6.0  <20140930003622.16B2760094@SIT-NAGIOS> Queued mail for delivery)
Sep 30 08:36:22 SIT-NAGIOS postfix/qmgr[989]: 16B2760094: removed
Sep 30 08:36:22 SIT-NAGIOS postfix/smtp[25566]: 21CA8600B3: to=<itnetworksupport@xxx.com>, relay=sit-smtp01.xxx.com[10.16.0.142]:25, delay=0.28, delays=0.01/0.01/0.01/0.24, dsn=2.6.0, status=sent (250 2.6.0  <20140930003622.21CA8600B3@SIT-NAGIOS> Queued mail for delivery)
Sep 30 08:36:22 SIT-NAGIOS postfix/qmgr[989]: 21CA8600B3: removed
Attachments
configV2.zip
(91.3 KiB) Downloaded 167 times
User avatar
millisa
Posts: 69
Joined: Thu Jan 16, 2014 11:13 pm
Location: Austin, TX
Contact:

Re: using contacts causing double email alert

Post by millisa »

You have the 'admins' contact group (contains itnetworksupport contact) defined in the 'generic-host' template used by the 6800SRETDB host. You have the the 'itdba' contact defined in the 'generic-service-dba' service template (that is also missing the register=0) that is included by the F drive service check. So the contacts that will get notified on 6800SRETDB's F Drive check will be 'itnetworksupport' and 'itdba' since both a contact_group and contact are being defined and you don't override the host's contact_group that is getting inherited.

I'll link the object inheritance documentation again, this time at the Implied Inheritance section.

Nagios will assume that you want to use a value that instead comes from a related object. For example, the values of some service variables will be copied from the host the service is associated with if you don't otherwise specify them.
Nagios Implied Inheritance
Nagios Implied Inheritance
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

milisa,

Change contact_groups to contact under the generic-host template do make all the all the service template that use contacts send out single mail alert. But cause other service template that use contact_groups to send double alert.
So does it mean nagios not allow to mix contacts and contact_groups settings in host/service notification?
BTW, it is by design for service contact notification to inherit object from host contact notification?

Code: Select all

# Generic host definition template - This is NOT a real host, just a template!

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1       ; Host notifications are enabled
        event_handler_enabled           1       ; Host event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
		check_command                   check-host-alive
		max_check_attempts              10
		notification_interval           240
		notification_period             24x7
		notification_options            d,u,r
		contacts                        itnetworksupport
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

# services template for DBA team
define service{
	name				generic-service-dba
	use				generic-service-template
	contacts			itdba
}

# services template for CIM team
define service{
	name				generic-service-cim
	use				generic-service-template
	contact_groups			cim-admins
}

Code: Select all

[1412089271] SERVICE NOTIFICATION: itnetworksupport;VSSCIMDB02;Physical Memory;CRITICAL;notify-service-by-email;SNMP CRITICAL - Physical Memory at 90% with 774 of 8,191 MB free
[1412089281] SERVICE NOTIFICATION: itdba;6800SRETDB;F Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - F:\ Label:New Volume  Serial Number 46939174 at 96% with 10,168 of 286,081 MB free
[1412089291] SERVICE NOTIFICATION: itcim;VSRMSHOST09A01;D Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - D:\ Label:New Volume  Serial Number 48ea7e57 at 89% with 4,502 of 40,957 MB free
[1412089291] SERVICE NOTIFICATION: itnetworksupport;VSRMSHOST09A01;D Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - D:\ Label:New Volume  Serial Number 48ea7e57 at 89% with 4,502 of 40,957 MB free
[1412089291] SERVICE NOTIFICATION: itmesproject;S-CEMSDB01;Physical Memory;CRITICAL;notify-service-by-email;SNMP CRITICAL - Physical Memory at 97% with 204 of 8,191 MB free
Attachments
nagios.log
(528.78 KiB) Downloaded 204 times
User avatar
millisa
Posts: 69
Joined: Thu Jan 16, 2014 11:13 pm
Location: Austin, TX
Contact:

Re: using contacts causing double email alert

Post by millisa »

I'm not sure I'm understanding the questions here but I'll try to answer.

There is an implied inheritance for contact_groups on services of a host that comes from the host (so that part is by design). I am unsure if a contacts setting on a host definition has an implied inheritance to the services of that host, it isn't mentioned in that table in the documentation. From your test it sounds like it might also be an implied inheritance, but I'd want to test this before making that statement myself. You can override any inherited value from earlier in an inheritance chain by setting a new value in the chain. If you want to remove a setting for something inherited earlier in the chain you can use the null setting like mentioned a couple pages ago. Services and hosts can have both contacts and contact_groups settings simultaneously and they are additive.

You appear to want to have notifications for a host's services that are different than a hosts own notifications. You use a top level 'generic-service-template' for most of your service chains, you could set both contacts and contact_groups in that generic-service-template to null and that should remove the implied inheritance of both that could get implied inherited from the host definition. Then you'd only have to worry about the contacts or contact_groups you set within the service chains.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: using contacts causing double email alert

Post by lmiltchev »

hata_ph, did milisa answer your question?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked