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

Report this snippet  

You need to login to post a comment.