Antwort: backslash in plugin output
John Relph
John.Relph at noaa.gov
Mon Nov 28 20:26:27 CET 2005
srunschke at abit.de writes:
>nagios-devel-admin at lists.sourceforge.net schrieb am 28.11.2005 18:09:36:
>
>> 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?
>
>Personally I am using a rather dirty hack to circumvent
>this problem. Back then I started researching more into
>this topic and the actual fault lies in the implementation
>of various printf binaries. Most printf binary implementations
>are prone to the poblem, but not all are - though I was too
>lazy to find out why that like that.
>
>I just know that the bash-builtin printf is doing its job
>correct. Therefor I forced Nagios into using the bash-builtin
>like this:
>
>define command{
> command_name notify-by-email
> command_line /bin/bash -c "printf \"%b\" \"***** Nagios
>*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService:
>$SERVICEDESC$\nHost: $HOSTNAME$\nDescription: $HOSTALIAS$\nAddress:
>$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATE$
>$TIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nProblem bestaetigen:
>http://nagios.abit.de/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=$HOSTNAME$&service=$SERVICEDESC$\""
>| /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTNAME$/$SERVICEDESC$ is
>$SERVICESTATE$ **" $CONTACTEMAIL$
> }
>
>This command is perfectly able to handle all an every \ in
>your output.
Almost! Instead of "\\foo\net.work" I see "oo
et.work". So the name does appear, but it still gets interpreted.
It would appear that I'll have to write some dirty perl hack to read
the variables from the command line and then send the email.
It does seem, however, that it should work out of the box.
-- 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