Only notify-service-by-email 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
ServerMonkey
Posts: 1
Joined: Fri Dec 27, 2013 3:40 pm

Only notify-service-by-email not working

Post by ServerMonkey »

I've run into an interesting problem using Nagios 3.5.1. The notify-host-by-email command works just fine, but notify-service-by-email doesn't even run the specified command line. No error is thrown or logged, it just silently goes nowhere. This is all I see in the logs:

Code: Select all

[1388177492] EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;artsci;http;3;michael;Testing notification
[1388177492] SERVICE NOTIFICATION: ops;artsci;http;CUSTOM (OK);notify-service-by-email;HTTP OK: HTTP/1.0 200 OK - 31151 bytes in 0.030 second response time;michael;Testing notification
The command definitions for both are very similar:

Code: Select all

define command{
        command_name    notify-host-by-email
        command_line /usr/sbin/nagmail --atype host --caddr $CONTACTEMAIL$ --ntype $NOTIFICATIONTYPE$ --hname $HOSTNAME$ --hstate $HOSTSTATE$ --haddr $HOSTADDRESS$ --hout $HOSTOUTPUT$ --ldtime $LONGDATETIME$
        }

define command{
        command_name    notify-service-by-email
        command_line /usr/sbin/nagmail --atype service --caddr $CONTACTEMAIL$ --ntype $NOTIFICATIONTYPE$ --sdesc $SERVICEDESC$ --halias $HOSTALIAS$ --sstate $SERVICESTATE$ --haddr $HOSTADDRESS$  --ldtime $LONGDATETIME$ --sout $SERVICEOUTPUT$
        }
The /usr/sbin/nagmail is a perl wrapper that I built to give me more control over debugging, SMTP settings, etc. But it isn't even being run when notify-service-by-email is called. I've confirmed that by having the script write a file each time it runs (whether it works or not), and that file is only written when Nagios calls notify-host-by-email.

Any ideas? I'm running under CentOS 6.5, using Nagios 3.5.1 from the EPEL yum repository.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Only notify-service-by-email not working

Post by abrist »

You may need to wrap the macros that could potentially have spaces with quotes. Without the quotes, the command may silently die when a space in a macro is interpreted as an argument separator.

Code: Select all

define command{
        command_name    notify-host-by-email
        command_line /usr/sbin/nagmail --atype host --caddr $CONTACTEMAIL$ --ntype $NOTIFICATIONTYPE$ --hname "$HOSTNAME$" --hstate $HOSTSTATE$ --haddr $HOSTADDRESS$ --hout "$HOSTOUTPUT$" --ldtime "$LONGDATETIME$"
        }

define command{
        command_name    notify-service-by-email
        command_line /usr/sbin/nagmail --atype service --caddr $CONTACTEMAIL$ --ntype $NOTIFICATIONTYPE$ --sdesc "$SERVICEDESC$" --halias "$HOSTALIAS$" --sstate $SERVICESTATE$ --haddr $HOSTADDRESS$  --ldtime "$LONGDATETIME$" --sout "$SERVICEOUTPUT$"
        }
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked