Page 3 of 4

Re: Unable to send notifications to contact SMS email

Posted: Thu Dec 15, 2016 9:38 am
by jsharris
After following the instructions in the linked document and producing a critical result on a service check I was able to get one notification successfully to a contact. All subsequent attempts have returned nothing at all with a variety of setting configurations. Some resulted in no notification being received but the notification history showing it had been sent some with nothing sent or received.

Running the notify_service_xi_contact command from a command line is successful.

Re: Unable to send notifications to contact SMS email

Posted: Thu Dec 15, 2016 1:08 pm
by tgriep
Can you post the settings for the command that you defined and the contact's settings so we can review it?

Re: Unable to send notifications to contact SMS email

Posted: Thu Dec 15, 2016 1:17 pm
by jsharris
Here is the contact:

Code: Select all

define contact {
	contact_name                  		sharris_cell
	alias                         		sharris_cell
	host_notifications_enabled    		1
	service_notifications_enabled 		1
	host_notification_period      		sharris_notification_times
	service_notification_period   		sharris_notification_times
	host_notification_options     		d,u,r,f,s,n,
	service_notification_options  		w,u,c,r,f,s,n,
	host_notification_commands    		notify_host_xi_contact
	service_notification_commands 		notify_service_xi_contact
	email                         		phonenumber@provider
	host_notifications_enabled    		1
	service_notifications_enabled 		1
	}
And the commands:

Code: Select all

define command {
       command_name                  		notify_host_xi_contact
       command_line                  		/usr/bin/php /usr/local/nagiosxi/scripts/contact_notification_handler.php --contactemail="$CONTACTEMAIL$" --subject="** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" --message="***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
}

define command {
       command_name                  		notify_service_xi_contact
       command_line                  		/usr/bin/php /usr/local/nagiosxi/scripts/contact_notification_handler.php --contactemail="$CONTACTEMAIL$" --subject="** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$ $SERVICEDESC$ is $SERVICESTATE$ **" --message="***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"
}
And the time period, in case it is needed as well:

Code: Select all

define timeperiod {
	timeperiod_name               		sharris_notification_times
	alias                         		Notification Times for sharris
	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
	sunday                        		00:00-24:00
	}

Re: Unable to send notifications to contact SMS email

Posted: Thu Dec 15, 2016 3:49 pm
by tgriep
If you look at the host and service notification options, you will see the letter n (none), that tells Nagios to never send a notification.

Code: Select all

   host_notification_options           d,u,r,f,s,n,
   service_notification_options        w,u,c,r,f,s,n,
So go in to the Core Config Manager > contacts menu, edit that contact, go to the Alert Settings tab and un-select none for the host and service notification options.
Save and apply the config and that contact should start to receive notifications.

Re: Unable to send notifications to contact SMS email

Posted: Fri Dec 16, 2016 7:54 am
by jsharris
I'm pretty sure that got set in desperation as the notifications appeared to be going out (based on history) but were not being received so I just set it to get notification for everything not catching that one the options is None (assuming this exists to overwrite anything from a template).

I have deselected None and it is again showing up in the history as having been processed but still nothing is being received.

Re: Unable to send notifications to contact SMS email

Posted: Fri Dec 16, 2016 10:36 am
by tgriep
Login to the XI server as root and run the following command and post the output.

Code: Select all

ll /usr/local/nagiosxi/scripts/
Run this command as root on the XI server.

Code: Select all

tail -f /usr/local/nagiosxi/tmp/phpmailer.log
Then in the GUI, go to Home > Host Details and select a host or service that contact is assigned to.
Click on the Advanced Tab and go to the Send custom notification menu.
Check the Forced and Broadcast boxes, fill in a comment and click the submit button.

In the window running the tail command, you should see the email being sent.
If you see any errors, copy them and post them so we can view them.

Also, look in this log file when you send the custom message for any errors.

Code: Select all

/usr/local/nagios/var/nagios.log
If you see any, post them.

Re: Unable to send notifications to contact SMS email

Posted: Fri Dec 16, 2016 10:44 am
by jsharris
Attached is the output from ll. Custom notification was received by user but nothing received by contact. No new information appeared in tail output.

Re: Unable to send notifications to contact SMS email

Posted: Fri Dec 16, 2016 11:00 am
by tgriep
In the nagios.log file, did you see the system try to send the custom notification to that user using the notify_host_xi_contact or notify_service_xi_contact command?
Can you post the settings for the host or service you used to test against so we can view the settings?

Re: Unable to send notifications to contact SMS email

Posted: Fri Dec 16, 2016 11:45 am
by jsharris
Sent another custom and this time it made it through to both recipients. Here is what was in the Nagios.log file:

Code: Select all

[1481905841] SERVICE NOTIFICATION: sharris;SHARRIS-PC;sharris-pc Adobe Acrobat Update Service;CUSTOM (OK);xi_service_notification_handler;Adobe Acrobat Update Service: Started;Scott Harris; Test 1130
[1481905841] SERVICE NOTIFICATION: sharris_cell;SHARRIS-PC;sharris-pc Adobe Acrobat Update Service;CUSTOM (OK);notify_service_xi_contact;Adobe Acrobat Update Service: Started;Scott Harris; Test 1130
Stopped the service being monitored and got the user notification but nothing for the contact. Contents of the Nagios.log for that event:

Code: Select all

[1481906215] SERVICE ALERT: SHARRIS-PC;sharris-pc Adobe Acrobat Update Service;CRITICAL;HARD;1;Adobe Acrobat Update Service: Stopped
[1481906215] SERVICE NOTIFICATION: sharris;SHARRIS-PC;sharris-pc Adobe Acrobat Update Service;CRITICAL;xi_service_notification_handler;Adobe Acrobat Update Service: Stopped
[1481906215] SERVICE NOTIFICATION: sharris_cell;SHARRIS-PC;sharris-pc Adobe Acrobat Update Service;CRITICAL;notify_service_xi_contact;Adobe Acrobat Update Service: Stopped
Service check config:

Code: Select all

###############################################################################
#
# Service configuration file
#
# Created by: Nagios Core Config Manager 2.6.2
# Date:	      2016-12-15 09:42:37
# Version:    Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND --- 
# Nagios CCM will overwrite all manual settings during the next update if you 
# would like to edit files manually, place them in the 'static' directory or 
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################

define service {
	host_name			SHARRIS-PC
	service_description		sharris-pc Adobe Acrobat Update Service
	check_command			check_xi_service_nsclient!******!SERVICESTATE!-l "Adobe Acrobat Update Service" -d SHOWALL!!!!!
	max_check_attempts		1
	check_interval			2
	retry_interval			1
	active_checks_enabled		1
	passive_checks_enabled		1
	check_period			xi_timeperiod_24x7
	flap_detection_enabled		0
	notification_interval		60
	notification_period		xi_timeperiod_24x7
	notification_options		w,c,r,
	notifications_enabled		1
	contacts			sharris,sharris_cell
	_xiwizard			windowsserver
	register			1
	}	

###############################################################################
#
# Service configuration file
#
# END OF FILE
#
###############################################################################

Re: Unable to send notifications to contact SMS email

Posted: Fri Dec 16, 2016 11:56 am
by jsharris
Attempted another custom notification; received by user but not by contact.
Turned monitored service back on; notification received by both user and contact.

It's the inconsistency that is killing me. It has become clear that the check works, the command works, and the notification works. But not all of it all of the time.