/ctdb/notify.sh

http://github.com/brinkman83/bashrc · Shell · 41 lines · 11 code · 7 blank · 23 comment · 0 complexity · b7a8f2b592ed0c85a733d12b626700a9 MD5 · raw file

  1. #!/bin/sh
  2. # This script is activated by setting CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
  3. # in /etc/sysconfig/ctdb
  4. # This is script is invoked from ctdb when node UNHEALTHY flag changes.
  5. # and can be used to send SNMPtraps, email, etc
  6. # when the status of a node changes
  7. event="$1"
  8. shift
  9. case $event in
  10. unhealthy)
  11. #
  12. # Send an snmptrap that the node is unhealthy :
  13. # snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb `hostname` 0 0 `date +"%s"` ctdb.nodeHealth.0 i 1
  14. #
  15. # or send an email :
  16. # mail foo@bar -s "`hostname` is UNHEALTHY" ...
  17. #
  18. # or do something else ...
  19. ;;
  20. healthy)
  21. #
  22. # Send an snmptrap that the node is healthy again :
  23. # snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb `hostname` 0 0 `date +"%s"` ctdb.nodeHealth.0 i 0
  24. #
  25. # or send an email :
  26. # mail foo@bar -s "`hostname` is HEALTHY" ...
  27. #
  28. # or do something else ...
  29. ;;
  30. startup)
  31. # do some extra magic when ctdb has started?
  32. ;;
  33. esac
  34. exit 0