Page 1 of 1

Nagios Responsive HTML Email Notifications Templates

Posted: Wed Sep 12, 2018 8:35 am
by ddunnt
hello,
I am trying to make our email notification look better (asked by management). I found "heiniha/Nagios-Responsive-HTML-Email-Notifications" script (https://github.com/heiniha/Nagios-Respo ... ifications) from Nagios Exchange. Could you help me add this to our Nagios XI? I do not know where or how to edit the file to makes this script work.

Sorry, basic linux skills.

Thanks,
Dempsey

Re: Nagios Responsive HTML Email Notifications Templates

Posted: Wed Sep 12, 2018 12:19 pm
by lmiltchev
Directions here are for Nagios Core, but they will work for Nagios XI as well. The basic steps would be:

1. SSH into your Nagios XI server, and download the package

Code: Select all

cd /tmp
wget https://github.com/heiniha/Nagios-Responsive-HTML-Email-Notifications/archive/GitHub.zip
2. Unzip the package

Code: Select all

unzip GitHub.zip
3. Move to the Nagios-Responsive-HTML-Email-Notifications-GitHub directory

Code: Select all

cd Nagios-Responsive-HTML-Email-Notifications-GitHub
4. Copy over the php-html-email to the plugins directory

Code: Select all

mv php-html-email/ /usr/local/nagios/libexec/
5. Change permissions of the directory you moved and files in it to nagios.nagios

Code: Select all

chown -R nagios.nagios /usr/local/nagios/libexec/php-html-email/
chmod -R 775 /usr/local/nagios/libexec/php-html-email/
6. Log into the Nagios XI web UI, so that you could add two new commands:

CCM > Commands > Add New

# Host command
Command Name = notify-host-by-email-html
Command Line = $USER1$/php-html-email/nagios_host_mail "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT$" "$SHORTDATETIME$" "$CONTACTEMAIL$" "$TOTALHOSTSUP$" "$TOTALHOSTSDOWN$" "$NOTIFICATIONAUTHOR$" "$NOTIFICATIONCOMMENT$" "$LONGDATETIME$" "$HOSTDURATION$" "$HOSTDURATIONSEC$" "$LASTHOSTCHECK$" "$LASTHOSTSTATECHANGE$" "$NOTIFICATIONISESCALATED$" "$HOSTATTEMPT$" "$MAXHOSTATTEMPTS$" "$NOTIFICATIONRECIPIENTS$" }
Command Type = misc command

Save

# Service Command
Command Name = notify-service-by-email-html
Command Line = $USER1$/php-html-email/nagios_service_mail "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$SHORTDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$CONTACTEMAIL$" "$SERVICEDURATIONSEC$" "$SERVICEEXECUTIONTIME$" "$TOTALSERVICESWARNING$" "$TOTALSERVICESCRITICAL$" "$TOTALSERVICESUNKNOWN$" "$LASTSERVICEOK$" "$LASTSERVICEWARNING$" "$SERVICENOTIFICATIONNUMBER$" "$LONGSERVICEOUTPUT$" "$NOTIFICATIONAUTHOR$" "$NOTIFICATIONCOMMENT$" "$SERVICEDURATION$" "$NOTIFICATIONISESCALATED$" "$SERVICEATTEMPT$" "$MAXSERVICEATTEMPTS$" "$NOTIFICATIONRECIPIENTS$"
Command Type = misc command

Save and Apply Configuration.

7. Now, you would need to change your contacts' notification commands to the ones that you just created.

CCM > Contacts > <you contact> > Alert Settings > Manage Host Notification Commands > notify-host-by-email-html > Add Selected > Close
CCM > Contacts > <you contact> > Alert Settings > Manage Service Notification Commands > notify-service-by-email-html > Add Selected > Close

Save and Apply Configuration.

Examples:
example01.PNG
example02.PNG
Important: Keep in mind that this method has some major disadvantages...

1. You are relying on a 3rd party script, that is not included in Nagios XI
2. You will have to modify all of your exiting contacts to use the new notification commands. If you have many contacts, this would be a tedious job.
3. When adding new contacts, you would have to set them up again with your "custom" commands.

A much better approach would be to use the Notifications Settings Management in Nagios XI:
example03.PNG
You can save templates, deploy them to some contacts or make them default to all contacts. There is no need to change the notifications commands. You can add HTML or CSS to the Host/Service subject and message fields in order to add color/styling, and make the notifications "pretty". I would recommend that you implement the second option.

Hope this helps.