Posted By

smoothnoodle on 11/21/06


Tagged

Bash osx heartbeatd failover highavailability


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fukami


Disable heartbeatd using Launchd and email administrator


 / Published in: Bash
 

Obviously you need to have heartbeatd handled by Launchd

  1. #!/bin/bash
  2.  
  3. ###
  4. # Stop heartbeatd so that failoverd initiates IPFailover
  5. # leaving network interfaces intact.
  6. ###
  7. # Setup mail
  8. ###
  9. C_NAME=`/usr/sbin/scutil --get ComputerName`
  10. NOTIFY="[email protected]"
  11. WARNING="Heartbeatd has been halted - Failover process initiated"
  12. ###
  13. # End Setup mail
  14. ###
  15. HEARTD=`/bin/ps -axcu | /usr/bin/grep -i heartbeatd > /dev/null; echo $?`
  16.  
  17. if [ ! ${HEARTD} -eq 0 ];
  18. then
  19. echo "heartbeatd is not running - uh oh..."
  20. /usr/bin/logger "FAILOVER: heartbeatd is not running - uh oh..."
  21.  
  22. echo From: ${C_NAME} - ${WARNING} > /tmp/heartbeat_warning.txt | mail -s \
  23. "FAILOVER PROCESS: Heartbeatd was not running" ${NOTIFY} < /tmp/heartbeat_warning.txt
  24. else
  25. launchctl unload /Library/LaunchDaemons/uk.ac.rave.heartbeatd.plist
  26. while [ $(/bin/ps -axcu | /usr/bin/grep -i heartbeatd > /dev/null; echo $?) -eq 0 ];
  27. do
  28. echo "Halting heartbeatd"
  29. /usr/bin/logger "FAILOVER: Halting heartbeatd"
  30. /bin/sleep 5
  31. done
  32.  
  33. echo "heartbeatd has been halted"
  34. /usr/bin/logger "FAILOVER: heartbeatd has been halted"
  35.  
  36. rm -f /var/run/heartbeatd.pid
  37.  
  38. echo From: ${C_NAME} - ${WARNING} > /tmp/heartbeat_warning.txt | mail -s \
  39. "FAILOVER PROCESS: Heartbeat halted - failover in process" ${NOTIFY} < /tmp/heartbeat_warning.txt
  40. fi
  41. exit 0

Report this snippet  

You need to login to post a comment.