/ctdb/events.d/01.reclock

http://github.com/brinkman83/bashrc · Shell · 46 lines · 40 code · 4 blank · 2 comment · 1 complexity · c90844e94909aa7a7ca2bb9f9f5a5efe MD5 · raw file

  1. #!/bin/sh
  2. # script to check accessibility to the reclock file on a node
  3. . $CTDB_BASE/functions
  4. loadconfig
  5. case "$1" in
  6. startup)
  7. ctdb_counter_init
  8. ;;
  9. monitor)
  10. RECLOCKFILE=$(ctdb -Y getreclock)
  11. ctdb_counter_incr
  12. (ctdb_check_counter_limit 200 >/dev/null 2>&1) || {
  13. echo "Reclock file $RECLOCKFILE\" can not be accessed. Shutting down."
  14. df
  15. sleep 1
  16. ctdb shutdown
  17. }
  18. [ -z "$RECLOCKFILE" ] && {
  19. # we are not using a reclock file
  20. ctdb_counter_init
  21. exit 0
  22. }
  23. # try stat the reclock file as a background process
  24. # so that we dont block in case the cluster filesystem is unavailable
  25. (
  26. stat $RECLOCKFILE && {
  27. # we could stat the file, reset the counter
  28. ctdb_counter_init
  29. }
  30. ) >/dev/null 2>/dev/null &
  31. ctdb_check_counter_limit 3 quiet
  32. ;;
  33. *)
  34. ctdb_standard_event_handler "$@"
  35. ;;
  36. esac
  37. exit 0