backslash in plugin output

John Relph John.Relph at noaa.gov
Mon Nov 28 18:09:36 CET 2005


Folks,

I'm running Nagios 1.2 with Nagios Plugins 1.4.2.  I am using the
check_disk_smb plugin to check the status of various Samba shares.  I
have noticed that although the name of the share shows up on the
Nagios status web page it does not show up in the notification emails
sent for that service.  For example, the Nagios web page displays the
status string "CRITICAL: Only 29.84G (2%) free on \\foo\bar.room", but
the notification email says only "CRITICAL: Only 29.84G (2%) free on".

I have tracked down the problem to the Nagios 'notify-by-email'
command definition in "etc/misccommands.cfg":

define command{
        command_name    notify-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification
 Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress:
 $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Inf
o:\n\n$OUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVI
CEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }

As you can see, that command definition uses "/usr/bin/printf" to
format a call to "/bin/mail" to send the notification message.  The
problem is that printf is attempting to interpret backslashes (because
of the "%b" format string) but Nagios is interpolating the values of
the variables without quoting backslashes in those values.
Specifically, $OUTPUT$ is "CRITICAL: Only 29.84G (2%) free on
\\foo\bar.room".  Which means that printf attempts to interpret "\f"
and "\b" in $OUTPUT$.  But those "codes" should not be interpreted.
They should be quoted.

This problem was previously reported on the nagiosplug-help list by
Sascha Runschke about a year ago (2004-11-03), but I could not find
any responses to that message in any Nagios or Nagios Plugin list.
Here's a link to the original message:

  http://sourceforge.net/mailarchive/message.php?msg_id=9953710

Does anybody have a solution for this problem?

	-- John

-- 
John Relph <John.Relph at noaa.gov>
NOAA/NESDIS/National Oceanographic Data Center


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click




More information about the Developers mailing list