Cool Stuff

Notifications using ISP SMTP server with Authentication

Description:

We needed to setup Nagios to utilize our internet service providers SMTP Email server for notification emails. The biggest problem was that the ISP’s outgoing email server requires authentication.

Current Version

1.0

Last Release Date

2010-01-17

Compatible With

  • Nagios 3.x

Project Notes
Nagios setup with SMTP outgoing authentications. These are instructions and examples on how we got this setup working. I hope this helps others in the Nagios community. This process utilizes a perl script called "sendEmail". 1) Download from http://caspian.dotconf.net/menu/Software/SendEmail. 2) Extract the file and copy the sendEmail into /usr/local/bin. 3) chmod +x /usr/local/bin/sendEmail. Now the setup and customization of Nagios. 1) Edit /usr/local/nagios/etc/resource.cfg - add (3) new entries. $USER5$=your_isp_email_address $USER6$=your_isp_email_password $USER7$=your_isp_outgoing_mail_server 2) Edit /usr/local/nagios/etc/objects/commands.cfg Change command_line for command_name notify-host-by-email: command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n" Change command_line for command_name notify-service-by-email: command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$" 3) Touch file /var/log/sendEmail 4) Chown nagios:nagios /var/log/sendEmail 5) Now restart Nagios service Testing: Go into Nagios and send an alert and check the /var/log/sendEmail log file. It should say "Email was sent successfully". Thats it. Your done and now using your ISP's email server with authentication. Sincerely, Hawkidav.
Reviews (5) Add a Review
just worked
by veehexx, August 31, 2014

Thanks for the guide - very clear and simple to setup. Since we're using unauthenticated system (lock down to IP addr), we simply deleted the -xn and -xp parameters which worked fine. We also had to replace the 'n' and 'nn' bits with n, as the site appears to of striped that out when you pasted it.



Download Link
by waikeong.chang, September 30, 2012

Where should i download this add-on?



New line issue and invalid SSL_version error
by WebHostingZone, July 31, 2012

Hi, First of all thank you for great script and for detailed installation instructions! I have found some issues during the installation: 1) invalid SSL_version error I got this error with latest Net::SSLeay (1.48) and IO::Socket::SSL (1.76) installed. To fix the error I downgraded IO::Socket::SSL to 1.68 version. To downgrade IO::Socket::SSL I followed the following steps: wget http://search.cpan.org/CPAN/authors/id/S/SU/SULLR/IO-Socket-SSL-1.68.tar.gz tar xzvf IO-Socket-SSL-1.68.tar.gz cd IO-Socket-SSL-1.68 perl Makefile.PL make make install After executing commands above TLS finally start working. 2) No line breaks in the email notification To fix this issue I just replaced 'n' in the command_line for notify_service_by_email and notify_host_by_email commands to '\n' I hope this helps to someone who will install sendEmail script after me! Best Regards, Eugene V. WebHostingZone.org



by vlavilla, October 31, 2011




sendEmail now with tls
by The_MoD, November 30, 2010

sendEmail does now support tls (you need the Perl modules Net::SSLeay and IO::Socket::SSL ) so i have modified the notify-host-by-email command line to: command_line /usr/local/bin/sendEmail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n" and the notify-service-by-email command line to command_line /usr/local/bin/sendEmail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$" Additionally i have added a few backslashes to the n's so that the Mails have a few line breaks and removed the unnecessary printf bacause the mailbody is allready added with the -m option



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.4 (8)
Favorites
2
Views
168,009