nagio send notification does not work

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
scott han
Posts: 6
Joined: Tue Oct 10, 2017 5:41 pm

nagio send notification does not work

Post by scott han »

Hi there,
I am struggling to use nagios notification for my customized service, so when the status of service turned into critical, I can receive email.
So I have the following definition for my service and comand

Code: Select all

define service {
	host_name			ult-tdc-test1
	service_description		synapse_bandwidth:5672
	servicegroups			synapse_bandwidth_servicegroup
	check_command		check_dummy!2!"no updates for the last 360 second(s)"!!!!!!
	is_volatile			0
	initial_state			u
	max_check_attempts		1
	check_interval			1
	retry_interval			1
	active_checks_enabled		0
	passive_checks_enabled		1
	check_period			24x7
	obsess_over_service		1
	check_freshness			1
	freshness_threshold		60
	event_handler_enabled		1
	flap_detection_enabled		0
	process_perf_data		1
	retain_status_information	1
	retain_nonstatus_information	1
	notification_interval		1
	first_notification_delay	1
	notification_period		24x7
	notification_options		w,c,u,r,f,s,
	notifications_enabled		1
	contacts			scott.han
	contact_groups		synapse
	stalking_options	o,w,c,u,
	notes_url			http://192.168.56.101/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$SERVICEDESC$
	register			1
	}
define contact {
	contact_name                  		scott.han
	alias                         		scott han
	host_notifications_enabled    		0
	service_notifications_enabled 		1
	host_notification_period      		24x7
	service_notification_period   		24x7
	host_notification_options     		d,u,s,n,
	service_notification_options  		w,u,c,r,f,s,n,
	host_notification_commands    		notify-host-by-email
	service_notification_commands 		notify-service-by-email
	can_submit_commands           		1
	retain_status_information     		3
	retain_nonstatus_information  		null
	email                         		[email protected]
	}
define contactgroup {
	contactgroup_name             		synapse
	alias                         		synapse contactors
	members                       		scott.han
	}
define command {
       command_name                  		notify-service-by-email
       command_line                  		/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info: $SERVICEOUTPUT$\n\nURL: $SERVICENOTESURL$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

define timeperiod {
	timeperiod_name               		24x7
	alias                         		24 Hours A Day, 7 Days A Week
	sunday                        		00:00-24:00
	monday                        		00:00-24:00
	tuesday                       		00:00-24:00
	wednesday                     		00:00-24:00
	thursday                      		00:00-24:00
	friday                        		00:00-24:00
	saturday                      		00:00-24:00
	}	
with these setting in place, I cannot receive any email when my service status turned into critical, it seems to me it does not automatically call the notify-service-by-email command when the status is changed into critical.
however if I go to nagios web gui, click the service, in the advanced tab use Send custom notification, then it works.
I am not sure what is missing here, or what i have done wrong.
Any help would be really appreciated.

Many thanks,
Scott

Thanks, after I delete the service and recreate, the notification is working now.
Last edited by scott han on Tue Feb 20, 2018 5:37 pm, edited 2 times in total.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: nagio send notification does not work

Post by mcapra »

You may try configuring the service to be volatile via the is_volatile directive. More info here:
https://assets.nagios.com/downloads/nag ... vices.html

Essentially, if you're receiving checks passively and want to alert *every single time* something "different" happens with a passive check's results, is_volatile is a good option.
Former Nagios employee
https://www.mcapra.com/
kyang

Re: nagio send notification does not work

Post by kyang »

Thanks for the help @mcapra!

scott han, take a look at mcapra's suggestion.

Let us know if you have any more questions.
Locked