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
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.