#!/bin/bash #/etc/keepalived/notify_action.sh log_file=/var/log/keepalived.log log_write() { echo "[`date '+%Y-%m-%d %T'`] $1" >> $log_file } [ ! -d /var/keepalived/ ] && mkdir -p /var/keepalived/ case "$1" in "MASTER" ) echo -n "$1" > /var/keepalived/state log_write " notify_master" echo -n "0" > /var/keepalived/vip_check_failed_count python /etc/keepalived/nexthop.py migrate >> $log_file 2>&1 & ;; "BACKUP" ) echo -n "$1" > /var/keepalived/state log_write " notify_backup" ;; "FAULT" ) echo -n "$1" > /var/keepalived/state log_write " notify_fault" ;; "STOP" ) echo -n "$1" > /var/keepalived/state log_write " notify_stop" ;; *) log_write "notify_action.sh: STATE ERROR!!!" ;; esac