Home Directory Addons Notifications Send HTML Alert Email v2

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Send HTML Alert Email v2

Rating
17 votes
Favoured:
3
Current Version
1.2
Last Release Date
2011-12-08
Compatible With
  • Nagios 3.x
  • Nagios XI
License
GPL
Hits
125936
Files:
FileDescription
nagios_service_mailThis php file sends HTML Service Related Alerts
nagios_host_mailThis php file sends HTML Host Related Alerts
a_11.pngThe Thumbnail Image in the Alert eMail
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
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...
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)
bysaracm118, March 25, 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!
bytsigl, November 21, 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!
bykavin.augusta, January 27, 2017
GOOD PLUGIN TO USE
bynihvel, August 24, 2016
1 of 1 people found this review helpful
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_info\r\n";

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!
Owner's reply

Wow! Really appreciate it! Thanks for the extra information.. This was really helpful in sprucing things up.

bymigas62, January 19, 2016
1 of 1 people found this review helpful
Very good work.
Could you tell me how i use this to send trough sendmail?
Owner's reply

Thanks for trying this out. Very much appreciated. As of now, its only written for php mailer. I'm pretty sure it could be done in sendmail as I have seen it been done. We just need to send the email content-type as html.

bysamf, January 18, 2016
1 of 1 people found this review helpful
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.
Owner's reply

Thanks for trying this out.. Very much appreciated! If you have any suggestions and recommendations, please let me know.

byckumara, June 30, 2014
2 of 2 people found this review helpful
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.
bywaikeong.chang, September 10, 2012
1 of 1 people found this review helpful
Where do i key-in the smtp details?
Owner's reply

Hi walkeong...
Its currently using the PHP mail() function which in-turn invokes the sendmail Linux command. You may need to configure the sendmail SMTP properties in order to send mails directly from PHP.. I will need to do a bit of reading on the sendmail application...

byTimeSearcher, April 17, 2012
3 of 3 people found this review helpful
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!
Owner's reply

Just realized a teeny mistake in my CMS related section.. Note: Its not SimpleCMS, but rather CMSimple(http://www.cmsimple.org/). CMSimple is free and ONLY required PHP to work (no MySQL).. In CMSimple, the URL contains the name of the Article Header - which means, you can set up Article Heading with the identical name as the Service Name in Nagios(No space allowed).. A special MACRO($SERVICESTATE$) in Nagios assigns the description of the Service..
All you need to do is change the URL of the CMS so it reflects the actual CMS URL on your system (possibly apache :-).