Retrospective IT

HTML Emails for Nagios

Nagios HTML Email Alerts

While Nagios notification alerts are great, they sure aren’t pretty.

Since the alerts in my company will be escalated to upper management, I wanted to clean them up a bit and make them pretty. To do this, I’ll using Nagios-HTML-Email (from Voxer) and will be doing the following:

  • Install npm
  • From npm, install nagios-html-email
  • configure Nagios and test

Short and sweet… The end result, should look like this:

Nagios HTML Email Alerts

The first thing we’ll need to do is install npm

apt install npm

Once that is completed, we can then install nagios-html-email

npm install -g nagios-html-email

Next, we need to edit nagios-html-email to change the env from node to nodejs

nano /usr/local/bin/nagios-html-email
#!/usr/bin/env node 

change to

#!/usr/bin/env nodejs

The last step is to change the notify-host-by-email and notify-service-by-email commands. These are located in /usr/local/nagios/etc/objects.command.cfg by default. We’ll be changing them to look like below:

# 'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    nagios-html-email host http://nagios-server-address/nagios/ | ssmtp -t

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    nagios-html-email service http://nagios-server-address/nagios/ | ssmtp -t

If you use anything other than sSMTP, you’ll need to adjust your email command at the end.

That’s it, trigger an alert and you should now have notification alerts that look a lot better.

Leave a Reply

Your email address will not be published. Required fields are marked *