notify_action.sh 856 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. #/etc/keepalived/notify_action.sh
  3. log_file=/var/log/keepalived.log
  4. log_write()
  5. {
  6. echo "[`date '+%Y-%m-%d %T'`] $1" >> $log_file
  7. }
  8. [ ! -d /var/keepalived/ ] && mkdir -p /var/keepalived/
  9. case "$1" in
  10. "MASTER" )
  11. echo -n "$1" > /var/keepalived/state
  12. log_write " notify_master"
  13. echo -n "0" > /var/keepalived/vip_check_failed_count
  14. python /etc/keepalived/nexthop.py migrate >> $log_file 2>&1 &
  15. ;;
  16. "BACKUP" )
  17. echo -n "$1" > /var/keepalived/state
  18. log_write " notify_backup"
  19. ;;
  20. "FAULT" )
  21. echo -n "$1" > /var/keepalived/state
  22. log_write " notify_fault"
  23. ;;
  24. "STOP" )
  25. echo -n "$1" > /var/keepalived/state
  26. log_write " notify_stop"
  27. ;;
  28. *)
  29. log_write "notify_action.sh: STATE ERROR!!!"
  30. ;;
  31. esac