Page 1 of 1

[Nagios-devel] backslash in plugin output

Posted: Mon Nov 28, 2005 9:09 am
by Guest
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/mess ... id=9953710

Does anybody have a solution for this problem?

-- John

--
John Relph
NOAA/NESDIS/National Oceanographic Data Center





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]