NagiosQL: formatting problem of emails

Hi all!

NagiosQL is sending poorly formatted notifications:


The command that generates this output is:

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$

This looks OK. Could it be the printf-version of Gentoo?


i’m not sure if this might be the problem, but it looks like your missing the backslash for your line breaks. that’s why it all runs together. take a look at my code below. :wink:

command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /bin/mail -s “$HOSTNAME$ IS $HOSTSTATE$!” $CONTACTEMAIL$

Edited Thu Oct 13 2005, 05:48AM ]

i just noticed when i replied that it removed the backslashes from my code also, so maybe this isn’t your problem.
Edited Thu Oct 13 2005, 05:49AM ]

Your command defintion looks wrong.

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 Info:\n\n$OUTPUT$" | /bin/mail -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$

Edited Thu Oct 13 2005, 05:41AM ]

that looks better jakkedup. :slight_smile: when i pasted my code, it blanked the backslashes.

Yup, now it looks decent. Thanks, man! 8)

One little suggestion: Replace ‘…Additional Info:\n\n$OUTPUT$…’ with ‘…Additional Info:\n\n$SERVICEOUTPUT$…’ 8)

Edited Thu Oct 13 2005, 08:49PM ]

The problem is somewhere in NagiosQL: When I use its interface to enter the correct command, it gets ‘mutilated’ to the (non-working) version at the top of this post… The only way to get the correct command in NagiosQL was editing the MySQL table directly… :x

I don’t know what nagiosql is, but it appears to be doing the same thing that your forum is doing. This forum, and nagiosql must be stripping out the backslash. In order to tell the forum and nagiosql to not do this, is to use TWO backslashes in a row, that way it says “look forum/nagiosql, then next backslash is a real character and not a command or something”.

So try your nagiosql thingy and use TWO backslashes instead of just one.
backslashbackslashnbackslashbackslashn =

I’ll check it out on monday… :frowning:

(Must be a PHP-thingie?)

Yea, I suppose it is. You also see that behavior in RegEx stuff with nagiostat.