keepalived check_script does not run as expected
08:01 01 Jul 2025

I have two VM's running keepalived. I have created a vrrp script to check if a container is running and if not decrease the priority of the vrrp node so that it causes a failover. However on the master node I get the below errors. I have also added my config files, anyone know why I get this error when there is only one vrrp? On the backup node the script runs and adjusts the weight as expected.

Starting Keepalived v2.2.8 (04/04,2023), git commit v2.2.7-154-g292b299e+
Keepalived[57489]: Running on Linux 5.14.0-503.31.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Mar 6 09:41:44 EST 2025 (built for Linux 5.14.0)

Keepalived[57489]: Command line: '/usr/sbin/keepalived' '--dont-fork' '-D'

Keepalived[57489]: Opening file '/etc/keepalived/keepalived.conf'.

Keepalived[57489]: Configuration file /etc/keepalived/keepalived.conf

Keepalived[57489]: NOTICE: setting config option max_auto_priority should result in better keepalived performance

Keepalived[57489]: Starting VRRP child process, pid=57491

Keepalived_vrrp[57491]: Registering Kernel netlink reflector

Keepalived_vrrp[57491]: Registering Kernel netlink command channel

Keepalived_vrrp[57491]: Assigned address 10.50.0.52 for interface ens192

Keepalived_vrrp[57491]: (VI_1) ignoring tracked script sc4s_health_check with weights due to address_owner

Keepalived_vrrp[57491]: Warning - script sc4s_health_check is not used

Keepalived_vrrp[57491]: Registering gratuitous ARP shared channel

Keepalived_vrrp[57491]: (VI_1) removing VIPs.

Keepalived[57489]: Startup complete

systemd[1]: Started LVS and VRRP High Availability Monitor.

Keepalived_vrrp[57491]: VRRP sockpool: [ifindex(  2), family(IPv4), proto(112), fd(12,13) multicast, address(224.0.0.18)]

Keepalived_vrrp[57491]: (VI_1) Receive advertisement timeout

Keepalived_vrrp[57491]: (VI_1) Entering MASTER STATE

Keepalived_vrrp[57491]: (VI_1) setting VIPs.

/etc/keepalived/keepalived.conf NODE1

! Configuration File for keepalived

global_defs {
   enable_script_security
   script_user root
   }

vrrp_script sc4s_health_check {
    script                      "/etc/keepalived/sc4s_health_check_script.sh"
    interval                    2
    weight                      20
    rise                        2
    fall                        2
}

vrrp_instance VI_1 {
    state                       MASTER
    interface                   ens192
    virtual_router_id           51
    priority                    255
    advert_int                  1
    authentication {
        auth_type               PASS
        auth_pass               #####
        }


    virtual_ipaddress {
        ####/26
    }
    track_script {
         sc4s_health_check
    }
}

/etc/keepalived/keepalived.conf NODE2


! Configuration File for keepalived

global_defs {
   enable_script_security
   script_user root
   }

vrrp_script sc4s_health_check {
    script                      "/etc/keepalived/sc4s_health_check_script.sh"
    interval                    2
    weight                      20
    rise                        2
    fall                        2
}

vrrp_instance VI_1 {
    state                       BACKUP
    interface                   ens192
    virtual_router_id           51
    priority                    254
    advert_int                  1
    authentication {
        auth_type               PASS
        auth_pass               ####
        }

    virtual_ipaddress {
        ####/26
    }

    track_script {
         sc4s_health_check
    }
}

/etc/keepalived/sc4s_health_check_script.sh

#!/bin/bash

if podman container exists SC4S; then
        exit 0
fi

if ss -ltn | grep ':514 '; then
        exit 0
fi

exit 1
bash keepalived