Contact Groups not working

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
bemenaker
Posts: 3
Joined: Thu Feb 16, 2012 1:15 pm

Contact Groups not working

Post by bemenaker »

I can not get my Nagios Core installation to send notifications to contact groups. It is only sending to what I have defined as the nagiosadmin, which is two people.

Code: Select all

Contacts:

define contact{
        contact_name                    nagiosadmin		; Short name of user
	use				generic-contact		; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin		; Full name of user
        email                           [email protected],[email protected]
        }


define contact{
	contact_name			dba1
	use				generic-contact
	alias				dba1
	email			[email protected]
	}

define contact{
	contact_name	        dba2
	use				generic-contact
	alias				dba2
	email			[email protected]
	}

define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin
        }

define contactgroup{
        contactgroup_name       dba
        alias                   dba
        members                 dba1,dba2
        }
I created this template for windows trying to use the new group, (to no avail):

Code: Select all

define host{
	name			windows-db	; The name of this host template
	use			generic-host	; Inherit default values from the generic-host template
	check_period		24x7		; By default, Windows servers are monitored round the clock
	check_interval		5		; Actively check the server every 5 minutes
	retry_interval		1		; Schedule host check retries at 1 minute intervals
	max_check_attempts	10		; Check each server 10 times (max)
	check_command		check-host-alive	; Default command to check if servers are "alive"
	notification_period	24x7		; Send notification out at any time - day or night
	notification_interval	30		; Resend notifications every 30 minutes
	notification_options	d,r		; Only send notifications for specific host states
	contact_groups		dba	; Notifications get sent to the admins by default
	hostgroups		windows-servers ; Host groups that Windows servers should be a member of
	register		0		; DONT REGISTER THIS - ITS JUST A TEMPLATE
	}
and here is a sample host:

Code: Select all

define host{
        use                          windows-server  <---- I have set this to my other template windows-db, that doesn't work either.
        host_name               report2
        alias                        report2
        address                    10.0.0.25        
	parents		       Core2 2960
	contact_groups	       dba,admins
	}
I am only sending notifications to the nagiosadmin, and I can't figure out why. It doesn't seem to be even trying to send to other contacts.
bemenaker
Posts: 3
Joined: Thu Feb 16, 2012 1:15 pm

Re: Contact Groups not working

Post by bemenaker »

bump to living up post.

Does anyone have any idea why this contact group isn't working? Everything I have tried has failed so far. I know that the nagios server can email the contacts I have created, I tested them by manually creating emails. I just can not get my host definitions to send to my groups.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Contact Groups not working

Post by mguthrie »

When dba1 and dba2 log in to the web interface, are they able to see their hosts correctly? If not, then maybe check the objects.cache file to verify that they're being compiled into the live config correctly.
bemenaker
Posts: 3
Joined: Thu Feb 16, 2012 1:15 pm

Re: Contact Groups not working

Post by bemenaker »

I can log into the web interface as both dba1 and dba2, and I can acknowledge events, schedule checks and everything. The only thing I'm not getting is notifications to these accounts.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Contact Groups not working

Post by mguthrie »

Maybe try a hard-coded test of the notification command that you're using.

Example:

Code: Select all

define command {
       command_name                             notify-host-by-email
       command_line                             /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
Try something simple like:

Code: Select all

su nagios -c ' /usr/bin/printf "%b" "***** Nagios Alert *****\n\nNotification Type: Type\nHost:TheHost\nState: TheState\nAddress:ADDRESS\nInfo:OUTPUT\n\nDate/Time: THDATE\n" | /bin/mail -s "** TYPE Host Alert:HOST is SOMETHING **" [email protected]'
This will at least verify that the nagios user can issue the alerts.
Locked