Jump to content

Nagios Alert Emailer


rev.dennis
 Share

Recommended Posts

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


}


 


send_mail.pl.txt


send_mail.pl.txt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...