You should check your printf command syntax (man printf) and change the notify-by-email command syntax in Nagios for your version of printf. Nagios prints e-mail thorugh printf and pipes it to mail command. You can see that in commands.cfg file in your /etc/nagios/ folder. Be sure you have %b argument in that command. It should be in “double quotes”. Like this:
Thanks for the reply. The commands are formatted correctly, and I don’t see anything in this version of printf that would cause the trouble. Sending the commands to stdout formats correctly.
I guess the problem must be something either sendmail or the exchange relay is doing?
Hm, hm… I think it’s in the printf format, because /usr/bin/mail just sends already formatted message to e-mail address specified. Sendmail and exchange don’t format mails. Is the mail subject formatted correctly when you get email?
If I put the command (in shell) like this (with qoutes ending before any \n and starting after \n):
/usr/bin/printf “%b” “***** Nagios ***"\n\n"Notification Type: $NOTIFICATIONTYPE$"\n\n"Service: $SERVICEDESC$"\n"Host: $HOSTALIAS$"\n"State: $SERVICESTATE$ for $SERVICEDURATION$"\n"Address: $HOSTADDRESS$"\n\n"Info:"\n\n"$SERVICEOUTPUT$"\n\n"Date/Time: $LONGDATETIME$"\n\n"ACK by: $SERVICEACKAUTHOR$"\n"Comment: $SERVICEACKCOMMENT$"\n | /usr/bin/mail -s " $NOTIFICATIONTYPE$ alert $NOTIFICATIONNUMBER$ - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
I get mail in this format:
***** Nagios *****nnNotification Type: $nnService: $nHost: $nState: $ for $nAddress: $nnInfo:nn$nnDate/Time: $nnACK by: $nComment: $n
which is very similar to yours. Those $ and $nHost: etc. are such because I’ve just c/p-ed the command from commands.cfg to the shell, modifying just mail address at the end.
Be sure you have correctly written the command like the one I c/p-ed in the earlier post (with doubleqoutes just in front of the message and at the end).
Can you post your notify-by-email command definition from commands.cfg?
Sure, I didn’t figure Sendmail would affect things, but I don’t know anythign about Exchange. Everything in nagios looks ok to me, but I’m probably missing something.
Dude, this is weird. Especially, if you say when you copy these commands to the shell and they send a normal mail (try every combination of this to make yourself sure commands are fine).
To me, it sends a normal mail when I copy this commands which you’ve posted to the sheel changing only mail recipient at the end. Same situation with the Nagios running these commands.
Some of my colleagues get emails through Exchange and everything works fine.
Probably something is defined wrong on your Nagios machine.