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.
Locked
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

using contacts causing double email alert

Post by hata_ph »

I am running Nagios 3.5.1 in Ubuntu 14.04 LTS and want to configure different contacts for different hosts/services
below is my contacts and services templates...

contacts_nagios2.cfg

Code: Select all

###############################################################################
# contacts.cfg
###############################################################################



###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################

# In this simple config file, a single contact will receive all alerts.

define contact{
        name                    contact-template
        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
	}

define contact{
        contact_name                    root
        alias                           Root
        use   contact-template
        email				xxx
	}

define contact{
        contact_name                    itdba
        alias                           IT DBA
        use                     contact-template
	email				xxxx
	}


###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 root
        }

define contactgroup{
        contactgroup_name       dbadmins
        alias                   DB Admins
        members                 itdba
        }
generic-services_nagios2.cfg

Code: Select all

# generic service template definition
define service{
        name                            generic-service-template ; The 'name' of this service template
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           0       ; Service notifications are enabled
        event_handler_enabled           1       ; Service 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
		#notification_interval           0		; Only send notifications on status change by default.
		notification_interval		60 # 30min
		is_volatile                     0
		check_period                    24x7
		normal_check_interval           5
		retry_check_interval            1
		max_check_attempts              1
		notification_period             24x7
		notification_options            w,u,c,r
		#contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

define service{
        name                            generic-service ; The 'name' of this service template
        use				generic-service-template
	#contact_groups                  admins
	contacts			root
        }

define service{
        name                            generic-service-dba ; The 'name' of this service template
        use				generic-service-template
	#contact_groups                  dbadmins
	contacts			itdba
        }
I use below service to check for disk size via snmp and all work fine...

Code: Select all

define service{
	use			generic-service-dba
	hostgroup_name		db-servers
	service_description	H Drive
	check_command		check_snmp_disk!public!H!70%!80%
}
If I configure generic-service-dba to use contacts instead of contact_groups, I will receive double email alert from nagios. If I change to use contact_groups, i will only receive 1 email alert...
so my question is, what is the different between contacts and contact_groups??
I also notice a similar problem in the forum http://support.nagios.com/forum/viewtop ... =7&t=28534 but no detail explanation about it

Code: Select all

[2014-08-21 10:39:51] SERVICE NOTIFICATION: itdba;6800SRETDB;H Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - H:\ Label:New Volume Serial Number 56a61c06 at 96% with 9,453 of 279,797 MB free
[2014-08-21 10:39:51] SERVICE NOTIFICATION: root;6800SRETDB;H Drive;CRITICAL;notify-service-by-email;SNMP CRITICAL - H:\ Label:New Volume Serial Number 56a61c06 at 96% with 9,453 of 279,797 MB free
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: using contacts causing double email alert

Post by tmcdonald »

My first question is related to your config names. contacts_nagios2.cfg and generic-services_nagios2.cfg leads me to believe you might just have redundant configs.
Former Nagios employee
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: using contacts causing double email alert

Post by sreinhardt »

Could you send us the full configurations both when it is sending a single email and when it is sending duplicates. My guess would be that your contact group or host group are both adding contacts and thus you are getting two sets, but I'd like to see them both just to be sure.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

tmcdonald, I run sudo nagios3 -v /etc/nagios3/nagios.cfg and no see any duplicate errors...

Code: Select all

administrator@SIT-NAGIOS:/etc/nagios3/conf.d$ sudo nagios3 -v /etc/nagios3/nagios.cfg

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/etc/nagios3/commands.cfg'...
Processing object config directory '/etc/nagios-plugins/config'...
Processing object config file '/etc/nagios-plugins/config/dns.cfg'...
Processing object config file '/etc/nagios-plugins/config/ldap.cfg'...
Processing object config file '/etc/nagios-plugins/config/disk.cfg'...
Processing object config file '/etc/nagios-plugins/config/dhcp.cfg'...
Processing object config file '/etc/nagios-plugins/config/mail.cfg'...
Processing object config file '/etc/nagios-plugins/config/radius.cfg'...
Processing object config file '/etc/nagios-plugins/config/rpc-nfs.cfg'...
Processing object config file '/etc/nagios-plugins/config/http.cfg'...
Processing object config file '/etc/nagios-plugins/config/ssh.cfg'...
Processing object config file '/etc/nagios-plugins/config/hppjd.cfg'...
Processing object config file '/etc/nagios-plugins/config/mysql.cfg'...
Processing object config file '/etc/nagios-plugins/config/load.cfg'...
Processing object config file '/etc/nagios-plugins/config/ifstatus.cfg'...
Processing object config file '/etc/nagios-plugins/config/pgsql.cfg'...
Processing object config file '/etc/nagios-plugins/config/ftp.cfg'...
Processing object config file '/etc/nagios-plugins/config/flexlm.cfg'...
Processing object config file '/etc/nagios-plugins/config/procs.cfg'...
Processing object config file '/etc/nagios-plugins/config/disk-smb.cfg'...
Processing object config file '/etc/nagios-plugins/config/netware.cfg'...
Processing object config file '/etc/nagios-plugins/config/telnet.cfg'...
Processing object config file '/etc/nagios-plugins/config/breeze.cfg'...
Processing object config file '/etc/nagios-plugins/config/dummy.cfg'...
Processing object config file '/etc/nagios-plugins/config/real.cfg'...
Processing object config file '/etc/nagios-plugins/config/users.cfg'...
Processing object config file '/etc/nagios-plugins/config/games.cfg'...
Processing object config file '/etc/nagios-plugins/config/snmp.cfg'...
Processing object config file '/etc/nagios-plugins/config/ping.cfg'...
Processing object config file '/etc/nagios-plugins/config/apt.cfg'...
Processing object config file '/etc/nagios-plugins/config/mailq.cfg'...
Processing object config file '/etc/nagios-plugins/config/ntp.cfg'...
Processing object config file '/etc/nagios-plugins/config/fping.cfg'...
Processing object config file '/etc/nagios-plugins/config/nt.cfg'...
Processing object config file '/etc/nagios-plugins/config/tcp_udp.cfg'...
Processing object config file '/etc/nagios-plugins/config/mrtg.cfg'...
Processing object config file '/etc/nagios-plugins/config/news.cfg'...
Processing object config directory '/etc/nagios3/conf.d'...
Processing object config file '/etc/nagios3/conf.d/sit-hyperv03.cfg'...
Processing object config file '/etc/nagios3/conf.d/contacts_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-ca.cfg'...
Processing object config file '/etc/nagios3/conf.d/cssfile.cfg'...
Processing object config file '/etc/nagios3/conf.d/extinfo_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/generic-service_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-hr.cfg'...
Processing object config file '/etc/nagios3/conf.d/smesdb.cfg'...
Processing object config file '/etc/nagios3/conf.d/services_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/smesapp.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-hyperv05.cfg'...
Processing object config file '/etc/nagios3/conf.d/s-dbtest.cfg'...
Processing object config file '/etc/nagios3/conf.d/localhost_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-mbx.cfg'...
Processing object config file '/etc/nagios3/conf.d/6800sretdb.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-ts.cfg'...
Processing object config file '/etc/nagios3/conf.d/ctc.cfg'...
Processing object config file '/etc/nagios3/conf.d/hostgroups_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/6800shdb.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-hyperv04.cfg'...
Processing object config file '/etc/nagios3/conf.d/s-hyperv01.cfg'...
Processing object config file '/etc/nagios3/conf.d/generic-host_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-hyperv01.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-wsus.cfg'...
Processing object config file '/etc/nagios3/conf.d/timeperiods_nagios2.cfg'...
Processing object config file '/etc/nagios3/conf.d/sit-hyperv02.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
        Checked 183 services.
Checking hosts...
        Checked 29 hosts.
Checking host groups...
        Checked 6 host groups.
Checking service groups...
        Checked 0 service groups.
Checking contacts...
        Checked 5 contacts.
Checking contact groups...
        Checked 4 contact groups.
Checking service escalations...
        Checked 0 service escalations.
Checking service dependencies...
        Checked 0 service dependencies.
Checking host escalations...
        Checked 0 host escalations.
Checking host dependencies...
        Checked 0 host dependencies.
Checking commands...
        Checked 155 commands.
Checking time periods...
        Checked 4 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
administrator@SIT-NAGIOS:/etc/nagios3/conf.d$
sreinhardt,
using the same contact_nagios2.cfg, if I use contacts instead of contact_groups I will get double emails. change to contact_groups, single email.

Code: Select all

define service{
        name                            generic-service ; The 'name' of this service template
        use            generic-service-template
   #contact_groups                  admins
   contacts         root
        }
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

below is my generic-host_nagios2.cfg

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           0
		notification_interval			60 # 60min
		notification_period             24x7
		notification_options            d,u,r
		contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: using contacts causing double email alert

Post by abrist »

Ah, it looks like you have defined the contact_group "admins" on the template. This will be inherited by the host and service checks it no other contact_groups are specified directly on the check objects. So when you define the "admins" contact_group on the check object, it overwrites the template and send only 1 email to the admins group, whereas applying the "root" contact directly on the object will cause 2 alerts - one to the admins group defined on the template (which I assume root is a member of ) and 1 to the "root" contact defined on the check object.

Honestly, from your config, I would suggest not setting either contacts or contact_groups on the check object if the group is already declared on the template and the users you would add to contacts on the check object already are members of the template group object.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

My notification planning was to create individual contact lists which use by it own dedicated services.
Take my configs for example, what ever check services under templates generic-service-dba will send alert messages to contact lists itdba.
I know in check services, you are allow to put contacts or contact_groups for notification contacts. At first I only use contacts for the notification.
But once i notice I am having double mail sending to root and itdba at the same time for the same alerts, i have to use contact_groups to send out 1 email alert to itdba only...
I have attached my nagios configuration together, maybe some can have a look did I do anything wrong?
Let me know if you have any question about my configuration...thanks in advance...
Attachments
config.zip
nagios config files
(4.19 KiB) Downloaded 214 times
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: using contacts causing double email alert

Post by abrist »

So, after you removed root from the admins contactgroup, are you still receiving duplicate notifications? If so, which contact is getting dupes?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
hata_ph
Posts: 31
Joined: Wed Aug 20, 2014 9:41 pm

Re: using contacts causing double email alert

Post by hata_ph »

this is my current config and root is no longer in my admins contact_groups. In my service check template, if i use contacts will get double emails. contact_groups will get single email...

Code: Select all

###############################################################################
# contacts.cfg
###############################################################################



###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################

# In this simple config file, a single contact will receive all alerts.

define contact{
        name                    contact-template
        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
   }

define contact{
        contact_name                    root
        alias                           Root
        use   contact-template
        email            xxx1
   }

define contact{
        contact_name                    itnetworksupport
        alias                           IT Network Support
        use                     contact-template
   email            xxxx2
   }


###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 itnetworksupport
        }

Code: Select all

# generic service template definition
define service{
        name                            generic-service-template ; The 'name' of this service template
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           0       ; Service notifications are enabled
        event_handler_enabled           1       ; Service 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
      #notification_interval           0      ; Only send notifications on status change by default.
      notification_interval      60 # 30min
      is_volatile                     0
      check_period                    24x7
      normal_check_interval           5
      retry_check_interval            1
      max_check_attempts              1
      notification_period             24x7
      notification_options            w,u,c,r
      #contact_groups                  admins
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

define service{
        name                            generic-service ; The 'name' of this service template
        use            generic-service-template
   #contact_groups                  admins
   contacts         root
        }

Code: Select all

S-PDPMSVR 	Physical Memory 	OK 	2014-08-29 09:44:29 	root 	notify-service-by-email 	SNMP OK - Physical Memory at 83% with 2,724 of 16,374 MB free
S-PDPMSVR 	Physical Memory 	OK 	2014-08-29 09:44:28 	itnetworksupport 	notify-service-by-email 	SNMP OK - Physical Memory at 83% with 2,724 of 16,374 MB free
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: using contacts causing double email alert

Post by abrist »

Which contact receive double notifications? root?
From your final code block, it looks like you are only sending notifications to root and itnetworksupport.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked