enable email alerts keepalived

Enable Email Alerts in Keepalived

Keepalived is a useful utility that helps you to maintain uptime in case of IP failovers between two or more servers. It is also used for load balancing and high-availability. It is advisable to setup email alerts in Keepalived so that system administrators are automatically alerted in case of issues. It can be configured to email admins whenever Keepalive switches from master to slave or vice versa. In this article, we will learn how to enable email alerts in Keepalived.


Enable Email Alerts in Keepalived

Here are the steps to enable email alerts in Keepalived.


1. Open Keepalived configuration file

Open terminal and run the following command to open Keepalived configuration file.

# /etc/keepalived/keepalived.conf


2. Update Configuration file

Add the following global settings. Replace admin@example.com with the email address of email recipient. Replace alert@example.com with the email address of sender that you want to be displayed in email alerts. Replace mail.example.com with the SMTP server domain. You may also need to provide your email password, in some cases, for authentication.

global_defs {
	notification_email {
        admin@example.com
	}
  notification_email_from alert@example.com
  smtp_server mail.example.com
  smtp_connect_timeout 30
# ...... Other configuration here .......
}

Add the following configuration for each VRRP instance.

vrrp_instance VI_1 {
# ...... Other configuration here .......
smtp_alert
# ...... Other configuration here .......
}

Save and close the instance.


3. Restart Keepalived Instance

Run the following command to restart Keepalived service.

# service keepalived restart

Your email alert will be similar to the following when VRRP instance goes to master state.

Subject: [hostname] VRRP Instance VI_1 - Entering MASTER state
Message: => VRRP Instance is now owning VRRP VIPs <=

You will receive the following email alert when VRRP goes to slave state.

Subject: [hostname] VRRP Instance VI_1 - Entering SLAVE state
Message: => VRRP Instance is nolonger owning VRRP VIPs <=

In this article, we have learnt how to enable email notifications in Keepalived.

Also read:

How to Use NMAP in Kali Linux
How to Install VirtualBox in Ubuntu
How to Pass Parameter in MySQL Query
How to Combine Querysets in Django
How to Get Field Value in Django Queryset

Leave a Reply

Your email address will not be published.