Okay, here is the /var/log/nagios.log message:
As you can see it's just trying to echo the output and it fails. I added the admin-test contact because we're seeing this exact same error with the email notification using printf. The error however is random. It doesn't occur 100% of the time. The above is the full text of the error with the exception of host/ip being altered. This also only seems to happen on service problems, NOT hosts.[1321474179] SERVICE NOTIFICATION: admin-test;somehost.here.com;CPU load;WARNING;notify-service-by-email-test;WARN - 15min Load 7.99 at 1 CPUs (warning at 5.00)
[1321474179] Warning: Attempting to execute the command "/bin/echo "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: CPU load\nHost: somehost.here.com\nAddress: 1.2.3.4\nState: WARNING\n\nDate/Time: Wed Nov 16 20:09:39 GMT 2011\n\nAdditional Info:\n\nWARN - 15min Load 7.99 at 1 CPUs (warning at 5.00)\n** PROBLEM Service Alert: somehost.here.com/CPU load is WARNING ** some@email.com\n-------------------\n" >> /var/log/nagios/service-test.log" resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists...
Here is the commands.cfg entry for admin-test, notify-service-by-email-test:
Here is the nagiosadmin/notify-service-by-email commands.cfg entry:command_line /bin/echo "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ ** $CONTACTEMAIL$\n------------\n" >> /var/log/nagios/host-test.log
Here is the same thing only with the printf email notification: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:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
As with the other error all I've done is masked the host/ip.[1321474179] SERVICE NOTIFICATION: nagiosadmin;somehost.here.com;CPU load;WARNING;notify-service-by-email;WARN - 15min Load 7.99 at 1 CPUs (warning at 5.00)
[1321474179] Warning: Attempting to execute the command "/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: CPU load\nHost: somehost.here.com\nAddress: 1.2.3.4\nState: WARNING\n\nDate/Time: Wed Nov 16 20:09:39 GMT 2011\n\nAdditional Info:\n\nWARN - 15min Load 7.99 at 1 CPUs (warning at 5.00)\n" | /bin/mail -s "** PROBLEM Service Alert: somehost.here.com/CPU load is WARNING **" some@email.com" resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists...
I initially thought some character was causing the problem but as far as I can tell the above service alert has worked on other hosts with similar names/characters. The fact it fails on a /bin/echo is stumping me completely. If anyone has suggestions or questions regarding the setup please let me know.