ICINGA 2 is an open source monitoring system which checks the availability of your network resources, notifies users of outages, and generates performance data for reporting. This tool works pretty well and its structure runs smoothly. But all of its features are useless if you will not be notified whenever a system in your network went down.
Today, we will discuss the step by step guide on how you can setup email alerts in Ubuntu 16.04 using SSMTP and Gmail account for Icinga notifications.
Let's Start:
Prerequisites:
- Ubuntu 16.04 Server
- Icinga 2
- Gmail Account
Setup:
Update Ubuntu Repository
$ sudo apt-get update
Install the SSMTP package
$ sudo apt-get install ssmtp
Install Postfix
$ sudo apt-get remove --purge postfix
$ sudo apt-get install postfix-mysql
On the next screen select "Internet Configuration"
Enter the domain of the site: gmail.com
Normally continue the installation
Install Mail Utilities
$ sudo apt-get install mailutils
Restart Icinga2 service
$ sudo systemctl restart icinga2
Configure SSMTP:
Edit the configuration file.
$ sudo nano /etc/ssmtp/ssmtp.conf
Adjust and add as necessary to match the following parameters.
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
root=<YourEmailAddress>@gmail.com
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=smtp.gmail.com:587
AuthUser=<YourEmailAddress>@gmail.com
AuthPass=<YourPassword>
UseTLS=YES
UseSTARTTLS=YES
# Where will the mail seem to come from?
#rewriteDomain=
rewriteDomain=gmail.com
# The full hostname
#hostname=MyMediaServer.home
hostname=<your hostname>
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
Create aliases for local usernames.
Edit the revaliases file.
$ sudo nano /etc/ssmtp/revaliases
Add the users as stated below.
root:<youremailaddress>@gmail.com:smtp.gmail.com:587
mainuser:<youremailaddress>@gmail.com:smtp.gmail.com:587
Allow Postfix on firewall:
If you are running the UFW firewall, we'll have to allow and exception for Postfix.
$ sudo ufw allow postfix
Configure Postfix:
$ sudo nano /etc/postfix/main.cf
Change mydestination value as seen below.
. . .
mydestination = gmail.com, localhost, localhost.localdomain
. . .
Setting Up Notifications
To get email notifications working, update the email address icinga is sending to:
$ sudo nano /etc/icinga2/conf.d/users.conf
Change the email line to the address you'd like to receive notifications at:
. . .
email= "<youremailaddress@gmail.com>"
. . .
RESTART ICINGA2 SERVICE
$ sudo systemctl restart icinga2
Check Setup:
To check the setup with verbosity output.
$ echo "test email" | sudo ssmtp -vvv <youremailaddress>@gmail.com
To check if icinga email notification is configured successfully.
$ echo "test email" | mail -s "test mail subject" <youremailaddress>@gmail.com
Setup ICINGA Email Alerts via SSMTP in Ubuntu 16.04
Reviewed by RigorMortis
on
December 22, 2017
Rating:
No comments: