Email notifications customization


Hi guys,

What i’d like to do is add a hyperlink in the nagios email notifications so that the hostname of the server with a problem is a link that brings up that host in nagios. How can i get sendmail to parse html code? Currently it sends all code as text and doesnt create the link.



Try creating the mail as HTML. You need to alter your content type etc in the header… After much trial and error I ended up with the following command object to send html mail (it’s for my high priority servers and it also sets the high priority flag) which you should be able to adapt… works OK for us outlook/exchange anyhow.

[blockquote]define command{
command_name nhost-html_email
command_line /usr/bin/printf “%b” “From:\nTo: $CONTACTEMAIL$\nSubject: ** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ \nMIME-Version: 1.0\nContent-Type: text/html";" charset=us-ascii\nX-Priority: 1 (Highest)\nX-MSMail-Priority: High\nContent-Transfer-Encoding: 7bit\nContent-Disposition: inline";" filename=“hostdownalert.html”\n\n*** Nagios *****

\nNotification Type: $NOTIFICATIONTYPE$
\n<p style=font-size:150%”;“color:red>\nHost: $HOSTNAME$
\nState: $HOSTSTATE$


\n” | /usr/sbin/sendmail -t




Thanks for the reply!

I keep getting the error either unmatched ". or when I add a quote, I get the error “missing name for redirect.” Any idea on how to fix that?


Couldn’t really speculate without seeing your command… if you can post it up it might shed some light on the problem.


I actually just copied and pasted your code above. I only modified the email address. I’m trying to run this on Nagios 2.3 on FreeBSD.


erk… well it works for me on 3.0.3, I can only assume some problem with the way 2.3 is interpreting the command. I seem to remember having many fun and games working out what characters to ‘escape’ in nagios to get it working compared to the line that would run from the shell without any problem, maybe your issue lies somewhere within needing to escape some of the quote characters as well. First though I would try and send a simple test message from the shell and get something working that way then try and crowbar it back into nagios… Otherwise, you could set up some sort of external shell script to create the email and point the command object to pass through your variables to that.