Antwort: backslash in plugin output

srunschke at abit.de srunschke at abit.de
Mon Nov 28 18:24:40 CET 2005


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.

Though you need to change it to fit your needs, I added
some sugar with the direct acknowledge link and such for
our non-pro Nagios users.

regards
        sash

--------------------------------------------------
Sascha Runschke
Netzwerk Administration
IT-Services

ABIT AG
Robert-Bosch-Str. 1
40668 Meerbusch

Tel.:+49 (0) 2150.9153.226
Mobil:+49 (0) 173.5419665
mailto:SRunschke at abit.de

http://www.abit.net
http://www.abit-epos.net
---------------------------------
Sicherheitshinweis zur E-Mail Kommunikation /
  Security note regarding email communication:
http://www.abit.net/sicherheitshinweis.html


-------------------------------------------------------
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