Home Directory Addons Notifications Notifications using ISP SMTP server with Authentication

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

Notifications using ISP SMTP server with Authentication

Rating
8 votes
Favoured:
2
Current Version
1.0
Last Release Date
2010-01-17
Compatible With
  • Nagios 3.x
Hits
168012
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!
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.
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)
byveehexx, August 22, 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.
bywaikeong.chang, September 10, 2012
Where should i download this add-on?
byWebHostingZone, July 14, 2012
1 of 1 people found this review helpful
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
byvlavilla, October 14, 2011
0 of 1 people found this review helpful
byThe_MoD, November 2, 2010
1 of 1 people found this review helpful
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 *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/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 *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$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