How to determine Keepalived switching state?

I'm currently using Keepalived on OpenWrt, but I've noticed that it doesn't support notify and notify_master.

I'm wondering how to detect the state when it switches to BACKUP and accordingly shut down the eth5 interface. When it switches back to MASTER, how can I open the eth5 interface? Can anyone provide guidance or suggestions? Thank you!

Hi!

FWIW, I am using the following script in /etc/keepalived.user (and retrieve /tmp/keepalived_status content with zabbix_agentd for monitoring):

case "$ACTION" in
        NOTIFY_MASTER)
                echo MASTER > /tmp/keepalived_status
                ;;
        NOTIFY_STOP | NOTIFY_BACKUP)
                echo BACKUP > /tmp/keepalived_status
                ;;
        *)
                logger "ERROR: unknown state transition (ACTION=$ACTION)"
                exit 1
                ;;
esac

chmod 644 /tmp/keepalived_status
1 Like