Home Directory Addons Notifications Notifications using ISP SMTP server with Authentication

Notifications using ISP SMTP server with Authentication

Bookmark and Share

Rating
3 votes
Favoured:
0
Current Version
1.0
Last Release Date
2010-01-17
Compatible With
  • Nagios 3.x
E-mail
Hits
46007
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 (2)
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
byvlavilla, October 14, 2011