Theodore Baschak

Routing Guru. BOFH. IPv6 Advocate. Founder/Operator of Hextet Systems (AS395089) and Network Architect for Daemon Defense Systems (AS55101).

HTML Email with Nagios

Sun, 07 Feb 2016 02:36:50 -0600 » Networking, Nagios, IPv6, Nerd Projects, Network Monitoring, System Administration » Estimated read time: 1 min

“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

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

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

Configuration

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 http://nagios.example.com | sendmail -t
}
define command {
    command_name notify-host-by-email
    command_line nagios-html-email host http://nagios.example.com | 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 - https://github.com/tbaschak - Powered by Jekyll.
Powered by Les.net.
This is a personal website. Opinions expressed are not necessarily those of his employer.