I have an event handler script that sends a formatted email. It works fine from the command line, however it's not working when Nagios attempts to activate it. Here are some details, names have been changed to protect the innocent:
Service Definition: define service{ use url-service host_name customer.server.net service_description http://customer.server.net check_command check_simple_url!http://customer.server.net event_handler open_outage!"Customer Corporation" } Command Definition: # 'open_outage' command definition define command{ command_name open_outage command_line /usr/local/nagios/libexec/eventhandlers/open_outage $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $SERVICEDESCRIPTION$ $ARG1$ } When I run the script by hand, manually specifying the five variables, it works swimmingly. The email is sent and all is well. This is what I see in the event log when it runs automatically: [09-28-2009 15:36:14] SERVICE EVENT HANDLER: customer.server.net;http://customer.server.net;(null);(null);(null);open_outage!"Customer Corporation" But our mail log is showing that no mail is actually sent. The actual script itself is listed below: #!/bin/sh # # Event handler script for opening CQ outages SERVICESTATE=$1 SERVICESTATETYPE=$2 SERVICEATTEMPT=$3 SERVICEDESCRIPTION=$4 CUSTOMERNAME=$5 DATE=$(date +%m/%d/%Y\ %r) openoutage() { cat <<EOF | /bin/mail -s "Outage submit" c...@ourmailserver.com Product: X_Application Outage_Type: Unplanned Outage Outage_Subtype: Server Issue Customers: $CUSTOMERNAME {Headline: $SERVICEDESCRIPTION is DOWN } {Description: Nagios was unable to poll $SERVICEDESCRIPTION three times in a row. Please investigate this outage as soon as possible. } {Customer_Experience: Customers and end-users will be unable to access the website. } {Customer_Impact: Site down, no access. } Timezone: CST Start_Time: $DATE Duration_Expected: 15 - 30 minutes EOF } # First we check what state the service is currently in case "$1" in OK) ;; WARNING) ;; UNKNOWN) ;; # CRITICAL is the state that we're interested in CRITICAL) # Next we check whether it's in a soft or hard state. case "$2" in SOFT) ;; HARD) case "$3" in 3) echo -n "URL has failed 3 checks and is in a hard state, opening CQ outage..." openoutage ;; esac esac ;; esac exit 0 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null