[Solved] Configuring notifications

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
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

[Solved] Configuring notifications

Post by jbruyet »

Hey all, I recently moved my Nagios from FreeBSD to CentOS 6.5. I've had a few hurdles to get over but things are running smoothly now.

I am in the process of configuring alerts and I'm trying to figure out my contacts.cfg file. I copied my file over from FreeBSD but it's configured quite a bit differently from what I'm seeing for Linux. Here's a sample I found on SourceForge ( http://nagios.sourceforge.net/docs/3_0/ ... ml#contact )

Code: Select all

define contact{
	contact_name	contact_name
	alias	alias
	contactgroups	contactgroup_names
	host_notifications_enabled	[0/1]
	service_notifications_enabled	[0/1]
	host_notification_period	timeperiod_name
	service_notification_period	timeperiod_name
	host_notification_options	[d,u,r,f,s,n]
	service_notification_options	[w,u,c,r,f,s,n]
	host_notification_commands	command_name
	service_notification_commands	command_name
	email	email_address
	pager	pager_number or pager_email_gateway
	addressx	additional_contact_address
	can_submit_commands	[0/1]
	retain_status_information	[0/1]
	retain_nonstatus_information	[0/1]
   	}
This is quite a bit different from what I was using so my question: is this a good example of what should go in a contacts.cfg file?

Thanks,

Joe B
Last edited by jbruyet on Tue Aug 19, 2014 6:36 pm, edited 1 time in total.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Configuring notifications

Post by tmcdonald »

That's a very robust config file, yes. You can always use templates if you don't want to fill in all values each time but what you have there will work just fine. Just out of curiosity, what did your contact configs look like on your FreeBSD system? They should have looked pretty similar.
Former Nagios employee
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Configuring notifications

Post by jbruyet »

Hi tmcdonald, I was just looking at my previous files and they run somewhat minimalistic. Here's my setup from contacts.cfg:

Code: Select all

# CONTACTS #################################
define contact{
    contact_name        JobeeMail
    use                 generic-contact
    alias               Nagios JobeeMail
    email               jobee@linktransit.com
    }

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

define contactgroup {
    contactgroup_name   EmailContacts
    alias               Email Contacts
    members             JobeeMail
    }
and I tossed in four lines for my... you know, I don't know what this section is called. It sits at the top of each one of my .cfg files:

Code: Select all

notification_period 24x7
        notification_interval 30
        notification_options d,u,s
        contact_groups EmailContacts
Sigh, I also see that I didn't mention that alerts aren't being sent out. I checked /usr/local/nagios/var/nagios.log and I don't see anything in there about alerts errors or otherwise.

Thanks,

Jobee
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Configuring notifications

Post by jbruyet »

DOH!!! Templates! I just realized there's another file -- templates.cfg. Here's the Contacts section from templates.cfg on my FreeBSD server:

Code: Select all

# Contacts
###############
define contact{
    name                            generic-contact
    alias                           Nagios Jobee
    service_notifications_enabled   1
    service_notification_period     24x7
    service_notification_options    c,u
    service_notification_commands   notify-service-by-email
    host_notifications_enabled      1
    host_notification_period        24x7
    host_notification_options       d,u
    host_notification_commands      notify-host-by-email
    email                           jobee@domain.com
    register                        1
    }
Ok, I have another avenue of exploration to go down.

Thanks,

Joe B
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Configuring notifications

Post by tmcdonald »

Check /var/log/maillog for entries relating to failed emails. It's possible they are sending but being rejected. Check the Notifications section in the web interface to see if Nagios *thinks* they are being sent.
Former Nagios employee
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Configuring notifications

Post by jbruyet »

Hi tmcdonald, I don't see any failed email entries in /var/log/maillog. I checked the Notifications and Nagios looks like it's sending notifications:

Code: Select all

Host 	Service 	Type 	Time 	Contact 	Notification Command 	Information
srv-dc3c 	Memory Check 	CUSTOM (OK) 	08-19-2014 16:17:01 	JobeePhone 	notify-service-by-email 	OK: physical memory: Total: 0.999G - Used: 529M (51%) - Free: 495M (49%)
srv-dc3c 	Memory Check 	CUSTOM (OK) 	08-19-2014 15:46:51 	JobeePhone 	notify-service-by-email 	OK: physical memory: Total: 0.999G - Used: 529M (51%) - Free: 494M (49%)


I can run

Code: Select all

echo "Wuzzup Guy" | mail -s "test email" 1234567890@vtext.com
from my Nagios server and I get the text message in about 15 seconds so my Nagios to Exchange connection is good.

Still looking...

Thanks,

Joe B
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Configuring notifications

Post by jbruyet »

Aha, I found something -- Nagios and Linux have different mail executable locations:

Linux

Code: Select all

[root@Nagios objects]# which mail
/bin/mail
[root@Nagios objects]#
and commands.cfg had

Code: Select all

/usr/bin/mail
Thanks,

Joe B
jbruyet
Posts: 235
Joined: Wed Dec 28, 2011 12:14 pm

Re: Configuring notifications

Post by jbruyet »

Yep, that did it. I just did another "Send custom service notification" and I got the text in about 20 seconds. Well ok then, we're off to the next step in getting the alerting configured for my devices that warrant that level of monitoring.

Thanks for the help,

Joe B
Locked