Notifications

Send HTML Alert Email v2

Description:

This is the Version 2 of the Previous Send HTML Alert Email.. Send your Alert Mails using HTML formatted emails.. I have tested this with Nagios v3.x only.. This may or may not work with Nagios v1 & v2 (As it requires the use of MACROS)…

Contains Useful Features Like —
1) Duration of the Problem Alert
2) Total Downtime of the Service upon Recovery
3) 4 Colored Coordinated Alerts
4) A thumbnail image in the Alert eMail to spice things up.

Requires less than 5 minutes to fully setup…

Current Version

1.2

Last Release Date

2011-12-08

Compatible With

  • Nagios 3.x
  • Nagios XI

Owner

License

GPL


Project Files
Project Photos
Project Notes
Download the two php files to the nagios/libexec/ folder and give them execution permission.. Open the two php files and check if the 1st line path/to/php and .ini files are correct, Also change the $from email variable to something more meaningful and real (Else your Email Server might Reject it / or SPAM it)... Now edit the nagios/etc/objects/command.cfg and replace the [notify-service-by-email] block with the following Block... define command{ command_name notify-service-by-email command_line /usr/local/nagios/libexec/nagios_service_mail "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$SHORTDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$CONTACTEMAIL$" "$SERVICEDURATIONSEC$" "$SERVICEEXECUTIONTIME$" "$TOTALSERVICESWARNING$" "$TOTALSERVICESCRITICAL$" "$TOTALSERVICESUNKNOWN$" "$LASTSERVICEOK$" "$LASTSERVICEWARNING$" "$SERVICENOTIFICATIONNUMBER$" } Also replace the [notify-host-by-email] code block with this block below... define command{ command_name notify-host-by-email command_line /usr/local/nagios/libexec/nagios_host_mail "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT$" "$SHORTDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$CONTACTEMAIL$" "$TOTALHOSTSUP$" "$TOTALHOSTSDOWN$" } (Check if the nagios/libexec folder paths are accurate before restarting)... Save the command.cfg file and restart the Nagios Service... The emails are sent using the PHP mail() function... A set oftemporary files are written to the root level /tmp folder in order to determine the Total Downtime upon Service Recovery... Many MACROS are used in order to boost the Usable Data, hence I am not sure if it will work on Older Nagios v2.0... [Optional Bonus]: If you have SimpleCMS installed, you can create a custom link which Network Staff can click and get the details of every single Service Type and Description... In order to do this, you will need to install the simplecms and create headings with Identical Names as the Service Name in Nagios.. The dummy domain kdog.cmsnagios.com was used as the Nagios WebSite.. The SimpleCMS was used to compliment the New Network Staff... For example: In Nagios/ Server Win32 DOG7 has a service name cpu_load (which describes the CPU), create a CMS heading cpu_load and write a detailed description about it.. You may email me for further descriptions on CMS Manipulations... Let me know if you have any queries regarding the 2 Email plugins... Would love to hear from you...
Reviews (9) Add a Review
Very good work.
by saracm118, March 31, 2020

For user-friendly State Duration, I would add this line in scripts $d = floor ($f_duration / 1440); $h = floor (($f_duration - $d * 1440) / 60); $m = round($f_duration - ($d * 1440) - ($h * 60)); and changed this line #$body .= "State Duration:$f_duration mins. "; to something like this $body .= "State Duration:$d days $h hours $m minutes "; anyway good job!



So happy I found this!
by tsigl, November 30, 2018

I was really struggling trying to set up a mail server for CentOS 7. I had tried multiple plugins and instructions for getting it to work prior to find this. This was so easy to set up and it works wonderfully!



GOOD PLUGIN TO USE
by kavin.augusta, January 31, 2017

GOOD PLUGIN TO USE



Wonderful!
by nihvel, August 31, 2016

I only wanted to give to the standard Nagios email template, the Bold and Italic formatting. Then I saw this. Less than 2 minutes to setup everything and worked at first try! Great job ;) Only things I want to note: 1. I use Nagios to read the log of lots of scripts of mine, I use performance data here because I can have more details BUT for these group of services I do not process them (process_perfdata 0). I find it useful to have them in the email, so I added: "$SERVICEPERFDATA$" at the end of notify-service-by-email. Modified the php: $extra_info= array_shift($argv); /*19*/ and added this row just below "Additional info": $body .= "Extra Info:$extra_inforn"; 2. I changed shebang to #!/usr/bin/env php not really a reason here, if not that I do not have /etc/php.ini but /etc/php5/apache2/php.ini /etc/php5/cli/php.ini What's important is that it works very very well!



Further instruction
by migas62, January 31, 2016

Very good work. Could you tell me how i use this to send trough sendmail?



Works for Nagios 4
by samf, January 31, 2016

It's a big improvement on the standard notification and is easy to understand and modify for my needs. It works on Nagios 4 as well.



Excellent HTML mail alert
by ckumara, June 30, 2014

With compared to the other few email alerts available in Nagios Exhange, this has a very simple configuration for Host & Services and nice HTML output with most important information. Instructions are also provided properly. I have tested it with Nagios 3.x and working fine. Highly commend to use it.



Further instruction
by waikeong.chang, September 30, 2012

Where do i key-in the smtp details?



A very simple but useful customization
by TimeSearcher, April 30, 2012

We used this "Send HTML Alert Email v2" customization kit to enhance our Nagios 3.2.0 deployment. It was easy to install & configure using the instructions provided. As advertised, our enhanced notifications were up and running in only 5 minutes. I highly recommend this package!



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.8 (17)
Favorites
3
Views
125,899