Keepalived : Set Email Notification2023/08/24 |
|
Set Email Notification when failover or failback happened. This example is based on the environment like follows.
VIP:10.0.0.30
+----------------------+ | +----------------------+
| [node01.srv.world] |10.0.0.51 | 10.0.0.52| [node02.srv.world] |
| Keepalived#1 +----------+----------+ Keepalived#2 |
| | | |
+----------------------+ +----------------------+
|
| [1] |
Install SMTP Server on all Nodes, refer to here. |
| [2] | In addition to basic Keepalived settings like here, set Email notification on all Nodes. |
|
root@node01:~#
vi /etc/keepalived/keepalived.conf
global_defs {
router_id node01
# add SMTP setting
notification_email {
root@localhost
}
notification_email_from root@node01.srv.world
smtp_server localhost
smtp_connect_timeout 30
}
vrrp_instance VRRP1 {
state MASTER
# nopreempt
interface enp1s0
virtual_router_id 101
priority 200
advert_int 1
virtual_ipaddress {
10.0.0.30/24
}
# add
smtp_alert
}
root@node01:~# systemctl reload keepalived
|
| [3] | That's OK. Verify Email notification. |
|
# node that some troubles happened root@node01:~# mail
"/var/mail/root": 2 messages 2 new
>N 1 root@node01.srv.wo Wed Aug 23 23:00 15/544 [node01] VRRP Instance VR
N 2 root@node01.srv.wo Wed Aug 23 23:00 15/543 [node01] VRRP Instance VR
? 2
Return-Path: <root@node01.srv.world>
X-Original-To: root@localhost
Delivered-To: root@localhost
Received: from node01.srv.world (localhost [IPv6:::1])
by node01.srv.world (Postfix) with SMTP id 19A1AA04BD
for <root@localhost>; Wed, 23 Aug 2023 23:00:52 -0500 (CDT)
Date: Wed, 23 Aug 2023 23:00:52 -0500
From: root@node01.srv.world
Subject: [node01] VRRP Instance VRRP1 - Entering FAULT state
X-Mailer: Keepalived
To: root@localhost
Message-Id: <20230824040052.19A1AA04BD@node01.srv.world>
=> VRRP Instance is no longer owning VRRP VIPs <=
# backup node root@node02:~# mail
"/var/mail/root": 1 message 1 new
>N 1 root@node02.srv.wo Wed Aug 23 23:00 15/538 [node02] VRRP Instance VR
? 1
Return-Path: <root@node02.srv.world>
X-Original-To: root@localhost
Delivered-To: root@localhost
Received: from node02.srv.world (localhost [IPv6:::1])
by node02.srv.world (Postfix) with SMTP id AD99DA04BF
for <root@localhost>; Wed, 23 Aug 2023 23:00:52 -0500 (CDT)
Date: Wed, 23 Aug 2023 23:00:52 -0500
From: root@node02.srv.world
Subject: [node02] VRRP Instance VRRP1 - Entering MASTER state
X-Mailer: Keepalived
To: root@localhost
Message-Id: <20230824040052.AD99DA04BF@node02.srv.world>
=> VRRP Instance is now owning VRRP VIPs <=
|
| Sponsored Link |
|
|