+91 88 00 563434 [email protected] Blog open-book Knowledge Base

Find Solutions in Our Knowledge Base

Enable Email Alerts in Keepalived

You are here:
Sharing is Caring

Keepalived is a routing software which is written in C. Keepalived is used to provide simple facilities for load balancing and high-availability to Linux system and Linux based infrastructures. Keepalived includes a set of checkers to dynamically and adaptively maintain, monitor and manage load balancing between the server according to their health. On the other hand, by using VRRP protocol high-availability is selected. VRRP is a basic brick for router fail-over. In addition, Keepalived includes a set of hooks to the VRRP finite state machine providing low-level and high-speed protocol interactions. Keepalived frameworks can be used independently or can be used all together to provide resilient infrastructures.

Keepalived is free software. You can redistribute it and modify it under the GNU General Public License. The Virtual Router Redundancy Protocol (VRRP) is a computer networking protocol. It helps to the automatic assignment of available Internet Protocol (IP) routers to participating hosts

Email alerts can set in your Keepalived configuration. By enabling this service will always give an alert to the users whenever the server switches from master to slave or slave to master. Whatever the motivation, email alerts provide a much more efficient method of managing systems than the manual managing of the system.  By using email alerts, you can easily get the information about disk space, performance reports, tell you to restart a critical process and also it tells you who is logged in, report unusual event.

How to Enable Email Alerts?

1) Make changes in Keepalived configuration file

/etc/keepalived/keepalived.conf

Add the following sections in the global settings.

global_defs

# addresses here are destinations for emails from the server

notification_email

[email protected]

[email protected]

# For clarity it is suggested that the from address

# given here is different on each server in the cluster

notification_email_from [email protected]

smtp_server mail.WebHostingPeople.net

smtp_connect_timeout 30

# ……. Other configuration here ………

router_id interserver_hostname-or-IP_address

Modify the values depending upon your needs. The router_id and notification_email_from option will be different for each server.

 2)Add smtp_alert into the VRRP instances section

vrrp_instance VI_1
state MASTER
interface eth0
virtual_router_id 5
priority 10
advert_int 1
smtp_alert
authentication
auth_type PASS
auth_pass 12345678

virtual_ipaddress
192.168.0.241/24

track_script
chk_vshell

Restart the service Keepalived

service keepalived restart

The Email alert will be like this:

When VRRP instance entered into master state

Subject: [hostname] VRRP Instance VI_1 – Entering MASTER state

Message: => VRRP Instance is now owning VRRP VIPs <=

When VRRP instance entered into slave state

Subject: [hostname] VRRP Instance VI_1 – Entering SLAVE state

Message: => VRRP Instance is nolonger owning VRRP VIPs <=


Sharing is Caring

Leave a Comment

Table of Contents