Notifications: script problems


#1

Hi,

I have configured Nagios 2.9 on my Gentoo server and I want to use email notifications to notify my colleagues and myself when some host or service goes down, but I can’t get that particular part to work.

I have written a little script send_mail_notification which I try to invoke with the notify_by_email and host_notify_by_email commands. This is the relevant part of my checkcommands.cfg file:

define command{
command_name notify-by-email
command_line sh /etc/nagios/send_mail_notification xyz@abc test test
}

define command{
command_name host-notify-by-email
command_line sh /etc/nagios/send_mail_notification xyz@abc test test
}

What this script does is just send an email to $1 with subject $2 and text $3. When I invoke this script from command line it works perfectly, both as root and as the nagios user.

I have tried debugging this for several hours, but I can only conclude that either the command is not executed, or there is still some permission problem going on.
I have tried replacing the “sh …” with a simple echo to file and that works, so the notification command gets invoked by Nagios.

What can I do? Is there a way to debug Nagios’ behavior and check what happens when it tries to invoke the “sh …” command?


#2

Ok, I’m just using the “printf …” from the sample configuration file now and that seems to work.