Advertisement
Guest User

ejabberd cluster instance check

a guest
Sep 17th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.09 KB | None | 0 0
  1. #!/bin/bash
  2. # 13.09.2019 Jonny Rimkus
  3. # Watchdog for ejabberd Cluster
  4. # 17.09.2019
  5. # add main ejabbderd node as variable
  6. # check if current node is missing from the cluster
  7. # and add it automatically or if -noauto arg was given return -1
  8.  
  9.  
  10. # path to ejabberdctl
  11. jabberctl="/usr/local/bin/ejabberdctl"
  12. # main ejabberd instance (node name for join_cluster)
  13.  
  14.  
  15.  
  16. # how many instances are in the cluster
  17. IN_CLUSTER=$($jabberctl list_cluster | grep "$nodemain" | wc -l)
  18.  
  19. if [ "$IN_CLUSTER" -lt 1 ]; then
  20.     if [ "$1" = "-noauto" ]; then
  21.         echo "$(date '+%d.%m.%Y %H:%M:%S')# instance is not in cluster '$nodemain'"
  22.         exit -1
  23.     fi
  24.  
  25.     # not all instances are running, do a join_cluster
  26.     echo -n "$(date '+%d.%m.%Y %H:%M:%S')# adding instance to cluster '$nodemain'..."
  27.     $jabberctl --no-timeout join_cluster "$nodemain"
  28.     if [ $? -ne 0 ]; then
  29.         echo -n "$(date '+%d.%m.%Y %H:%M:%S')# error!"
  30.         exit $?
  31.     fi
  32.     echo "$(date '+%d.%m.%Y %H:%M:%S') done"
  33. else
  34.     # nothing to do, all instances
  35.     echo "$(date '+%d.%m.%Y %H:%M:%S')# all instances are running"
  36. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement