NagiosQL: formatting problem of emails

Hi all!

NagiosQL is sending poorly formatted notifications:

""*****""Nagios""*****nnNotification""Type:""PROBLEMnnService:""check_ntpnHost:""www.gipz.comnAddress:""127.0.0.1nState:""CRITICALnnDate/Time:""Thu""Oct""13""13:59:12""CEST""2005nnAdditional""Info:nnNTP""CRITICAL:""server""127.0.0.1,""stratum""2,""offset""-0.000000,""delay""0.02563""

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?

evert,

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 =
\n\n

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.