Line breaks in notifications ignored

Heiko Schlittermann hs at schlittermann.de
Wed Nov 21 23:30:05 CET 2007


Tal Cohen <nagios at cohen123.com> (Mi 21 Nov 2007 15:35:51 CET):
> Looks like the back slash is getting escaped out. Try double backslashes:
> \\n instead of \n.
> 
> archives, google, and my own archives (since I joined the list) and can't
> seem to find where I saw this mentioned before. I have notification commands
> such as: 
> 
> define command{ 
>         command_name    host-notify-by-email 
>         command_line    /usr/bin/printf "%b" "** Nagios **\n\nNotification
> Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress:
> $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" |
> /usr/bin/mailx -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ 
>         } 
> 
> When I run: /usr/bin/printf "%b" "** Nagios **\n\nNotification Type" from
> the command line it appears correctly, with the \n inserting a line break,
> however when Nagios sends an alert I get the alert with no line breaks and
> an"nn" or "n" (depending on the break) where it should have been. I am
> stumped at the moment. I have been over the docs but only found the macros

If you tested it on the command line - are you sure about the printf you
used? 

    printf is a shell builtin
    printf is /usr/bin/printf
    printf is /usr/bin/X11/printf

(Here /usr/bin/printf behaves correctly, but it's not your system ;-)

    Best regards from Dresden
    Viele Grüße aus Dresden
    Heiko Schlittermann
-- 
 SCHLITTERMANN.de ---------------------------- internet & unix support -
 Heiko Schlittermann HS12-RIPE -----------------------------------------
 gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
 gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2  7E92 EE4E AC98 48D0 359B -
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://www.monitoring-lists.org/archive/users/attachments/20071121/7223b206/attachment.sig>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at 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


More information about the Users mailing list