#!/bin/bash

keepalived_status=$(cat /etc/keepalived/keepalived_dhcpd.txt | grep STATUS |cut -f 2 -d'=')
if [[ "${keepalived_status}" = "MASTER" ]]
then
	if ! pgrep -x "dhcpd" > /dev/null; then
	    logger "Keepalived: DHCP server is down, triggering failover."
	    exit 1  # 触发 `notify_fault`
	else
	    exit 0  # DHCP 正常
	fi
else
	    exit 0  # DHCP 正常
fi

