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.
colinjack
Posts: 16
Joined: Thu Nov 21, 2013 12:01 pm

contact_groups not working

Post by colinjack »

I am new on here - hope someone can give me a pointer.

I have installed Nagios Core 4.01 on Centos 6 and all is working fine.

Initially I just set up using the default setup (adjusted to suit my environment). My problem is with email notifications.

If I leave the hosts to inherit the admins contact_group from the template it all works fine. Email alertss get sent out as expected.

I want to have different notification groups for different hosts, so added a second contactgroup to contacts.cfg with suitable contact defined:

define contact{
contact_name secondline
use generic-contact
alias James
email james@domain.com
}

define contactgroup{
contactgroup_name secondline
alias Second Line Support
members secondline
}

I then added the contact_groups variable to the host:

define host{
use cluster-host
host_name Cluster 2
address 192.168.10.222
hostgroups cluster-hosts
contact_groups secondline
}

Alerts for Cluster 2 still come to the default admins contacts group, but not to the new secondline group. I expected the host setting to override the template setting.

Can anybody see what I am doing wrong? Seems pretty straight forward to me :?

Thanks

Colin
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: contact_groups not working

Post by slansing »

To me it looks like you have the contactgroup secondline defined, you are pulling it into the service, but the only member of the group you have defined is called secondline and that only has the single address, you need to create a new contact for each additional address, and define that contact in the contactgroup.
colinjack
Posts: 16
Joined: Thu Nov 21, 2013 12:01 pm

Re: contact_groups not working

Post by colinjack »

slansing wrote:To me it looks like you have the contactgroup secondline defined, you are pulling it into the service, but the only member of the group you have defined is called secondline and that only has the single address, you need to create a new contact for each additional address, and define that contact in the contactgroup.
I do have other addresses defined and added to the admins group - and that works fine. The problem is that the admin group still gets alert emails for cluster 2 even though I only have the second line group in the contact_groups variable. What I cannot understand is why Nagios is ignoring that entry and using the default from the template (i.e. admins). I would expect alerts for Cluster 2 to only go to that one email address (james@domain.com).

I have left all the other entries from contacts.cfg and linuxhosts.cfg off my post to avoid a huge post - just posted the relevant entries.
colinjack
Posts: 16
Joined: Thu Nov 21, 2013 12:01 pm

Re: contact_groups not working

Post by colinjack »

Right - I have come to this from a different direction ;)

1. Created a new user and group in contacts.cfg:

define contact{
contact_name colintest
use generic-contact
alias Colin Test
email test@icloud.com
}

define contactgroup{
contactgroup_name testgroup
alias Test Administrator
members colintest
}

2. I have then created a new host entry for a fictitious host (so this will fail every test :D )

define host{
use linux-server
host_name Test Server 1
address 200.21.100.160
hostgroups linux-servers
contact_groups testgroup
}

3. Restart nagios service ... let's see what happens! I should get alerts in my iCloud account.
colinjack
Posts: 16
Joined: Thu Nov 21, 2013 12:01 pm

Re: contact_groups not working

Post by colinjack »

Hmmm ... well that didn't work either.

I must be missing something but what? Anybody able to help?

Thanks
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: contact_groups not working

Post by lmiltchev »

Can you show us the " linux-server" template definition? Do you see anything in the mail log?

Code: Select all

tail -50 /var/log/maillog
Be sure to check out our Knowledgebase for helpful articles and solutions!
colinjack
Posts: 16
Joined: Thu Nov 21, 2013 12:01 pm

Re: contact_groups not working

Post by colinjack »

define host{
name linux-server
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period workhours
notification_interval 120
notification_options d,u,r
contact_groups admins
register 0
}


Tail on maillog just shows the emails for admins group - which I receive. The admins contactgroup works fine.The problem just seems to be with trying to get another contact group to work.

Thanks for the help - has to be something silly that I'm missing although I can't think where.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: contact_groups not working

Post by slansing »

Are the notifications for the other group showing up under Reports > Notifications? If they show up there, but not in the maillog it's likely an issue with the email handlers for that contact.
colinjack
Posts: 16
Joined: Thu Nov 21, 2013 12:01 pm

Re: contact_groups not working

Post by colinjack »

Notification report only shows notifications that are working (and were emailed). The whole system works fine apart from this second contact group. I need to spend a bit more time checking through I reckon.

I have created a new 'vanilla' 4.0.1 install on a new Centos 6 VM to play with over the weekend to see if I can get to the bottom of it. ;)

Appreciate the help.

Colin
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: contact_groups not working

Post by slansing »

Great well let us know what you come up with! I do understand that is how the report works, that's why I wanted you to verify if it shows the emails there or not.
Locked