1

I just set up the notification script in /etc/keepalived/keepalived.conf

/etc/keepalived/keepalived.conf

global_defs {
  notification_email {
    admin@example.com
  }
  notification_email_from keepalived@example.com
  smtp_server 127.0.0.1
  smtp_connect_timeout 30
  router_id DEFAULT_ROUT_ID
}


vrrp_script notification {
  script ""
  interval
  weight
}

vrrp_instance VI_1 {
  interface eth0
  virtual_router_id 10
  nopreempt
  state backup
  priority 110
  advert_int 1
  virtual_ipaddress {
    22.22.22.22
  }
  track_script {
    notification
  }

  notify_master "/etc/keepalived/master.sh"
  notify_backup "/etc/keepalived/backup.sh"
}

And Whenever the state changes, it comes out

enter image description here

It seems working but those shellscripts are not executed.

Do you have any suggestion?

Peco
  • 153
  • 2
  • 2
  • 8
  • I've actually seen the same. I moved the lines to another location in the instance definition and then they worked.... – svrist Mar 17 '16 at 13:47

2 Answers2

3

I had this same issue too, my notify script wasn't being executed, at the end of the day, I realized SELinux was blocking my script from being run, I found this out by typing:

[root@server ~]# journalctl

so go through the output, it will give you a hint as to the command to disable SELinux so your notify script can run. Also, I didn't use notify but

      notify_master "/path/to/script"
      notify_backup "/path/to/script"

Result from SELinux: If you believe that keepalived should have the dac_override capability by default. Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing these commands:

   ausearch -c 'keepalived' --raw | audit2allow -M my-keepalived

   semodule -i my-keepalived.pp

Once you run these commands, restart keepalived:

   service keepalived restart
0

In my case, I had to specify the full path (rightfully).

Feb 14 17:14:01 lb0-0 Keepalived_vrrp[22728]: WARNING - script `killall` resolved by path search to `/usr/bin/killall`. Please specify full path.
Feb 14 17:14:01 lb0-0 Keepalived_vrrp[22728]: Cannot find script  in path
Feb 14 17:14:01 lb0-0 Keepalived_vrrp[22728]: Disabling track script chk_haproxy since not found
William
  • 266
  • 1
  • 4
  • 18