Linux

Nagios Alert Emailer

Description:

A direct replacement for the basic nagios email command. This perl script will take standard Nagios commandline parameters and send an email to a configured email server, recipient and address.

Current Version

Last Release Date

June 18, 2009

Compatible With


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!
Project Files
Project Notes
This script is a direct replacement for the basic Nagios emailer. This perl script provides the following features: * Allows you to specify the senders email address * Allows you to specify the destination email address/group * Allows you to differentiate between Host and Service outages * Allows you to connect directly to any SMTP server * Doesn't require any local sendmail configuration * Uses standard Net::SMTP module * Runs within Nagios's embedded perl interpreter * Allows you to format the alert message subject and body * Allows you to send emails to different alert groups based on nagios configuration Configuration steps -------------- I put this in the nagios plugins directory /usr/local/nagios/libexec but you can put it anywhere. commands.cfg --- define command{ command_name notify-by-email command_line $USER1$/send_mail.pl -n "$NOTIFICATIONTYPE$" -h "$HOSTNAME$" -s "$HOSTSTATE$" -a "$HOSTADDRESS$" -i "$HOSTOUTPUT$" -d "$LONGDATETIME$" -e "$CONTACTEMAIL$" } define command{ command_name host-notify-by-email command_line $USER1$/send_mail.pl -n "HOST $NOTIFICATIONTYPE$" -h "$HOSTNAME$" -s "$HOSTSTATE$" -a "$HOSTADDRESS$" -i "$HOSTOUTPUT$" -d "$LONGDATETIME$" -e "$CONTACTEMAIL$" } define command{ command_name service-notify-by-email command_line $USER1$/send_mail.pl -n "SERVICE $NOTIFICATIONTYPE$" -h "$HOSTNAME$" -s "$SERVICESTATE$" -a "$HOSTADDRESS$" -i "$SERVICEDESC$ - $SERVICEOUTPUT$ - $SERVICECHECKCOMMAND$" -d "$LONGDATETIME$" -e "$CONTACTEMAIL$" } contacts.cfg --- define contact{ contact_name contact host_notification_commands host-notify-by-email service_notification_commands service-notify-by-email email email@address.com .... rest of contact details .... }
Reviews (2) Add a Review
modern versions of Net::SMTP need removed
by john_lines, February 28, 2014
In my systems which run Debian Wheezy I needed to remove the
at the end of the datasend lines i.e.

$smtp->datasend("To: $mailto");
$smtp->datasend("From: $mailfrom");
$smtp->datasend("Subject: $mailsubject");
$smtp->datasend("
");

so that the headers acually are taken as headers.

I also set the subject as:
# $mailsubject = "Nagios Monitoring Alert: $opt_h is $opt_s";
$mailsubject = "$opt_n: $opt_h $opt_D is $opt_s";

which maximises the information in a view of mail messages with just headers, to prioritise dealing with alerts
Helpful? Yes  No 
by dimsum, October 31, 2011

Helpful? Yes  No 
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 (2)
Favorites
0
Views
184,001