Nerd blog.

07 Feb 2016

HTML Email with Nagios

“But can you make the alerts look nicer?”

I’ve always liked the simple, plain text, easily customized commands used for email and SMS alerting in Nagios. I recently set up SMS alerting using nagios-twilio and some custom alert commands. Knowing this, I knew it would be possible to add HTML formatted alerts, and easily too.

I did a quick google and found the following blog post from Voxer, and accompanying github project. I’ve long been tempted by Etsy’s HTML email generating NOW WITH CONTEXT, nagios-herald which I discovered in this excellent blog blog however I hadn’t been running anything graphing perfdata up until recently.


Installation of nagios-html-email was pretty straight forward:

sudo apt-get -y install npm
sudo npm install -g nagios-html-email


As the README states, you need the notification commands. I chose to add a new command instead of replacing the existing one.

define command {
    command_name notify-service-by-email
    command_line nagios-html-email service | sendmail -t
define command {
    command_name notify-host-by-email
    command_line nagios-html-email host | sendmail -t

In my case, I had to replace mailx with sendmail because the emails were coming through with literal HTML code in them instead of being interpreted. I also had to edit the first line of the script at /usr/local/bin/nagios-html-email to change node to nodejs.

At this point I tested a few test notifications and was was quite pleased with the default notification template. I am going to run it for a while and see what I’d like to customize.


Theodore Baschak - Theo is a network engineer with experience operating core internet technologies like HTTP, HTTPS and DNS. He has extensive experience running service provider networks with OSPF, MPLS, and BGP.