keepalived mail notification

 

To get mail alerts from keepalived(on every start change from MASTER to BACKUP or BACKUP to Master) we need to add following code in keepalived.conf file:

global_defs {
  notification_email {
    user@hostname.com
  }
  notification_email_from lb-alert@hostname.com
  smtp_server your.smtpserver..com
  smtp_connect_timeout 30
}

Next add following line in keepalived.conf’s vrrp_instance VI_1 block:

smtp_alert

After adding smtp_alert in vrrp_instance VI_1 block your code looks like below:

vrrp_instance VI_1 {
  ...Your Code...
  ...Your Code...
  ...Your Code...
  smtp_alert
  ...Your Code...
  ...Your Code...
  ...Your Code...
}

After making above two changes restart keepalived.

$ service keepalived restart