From 26f5a0e42ba95a2082b3d645a76f6fdc134b8d1f Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 7 Feb 2019 16:16:49 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index ceb8271f..a4600ad3 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -22,8 +22,8 @@ STATUS() { echo declare -i cw; declare -i spc1; declare -i c if [ ! -z ${LOCAL_SERVICES+x} ]; - then NCMD='ssh root@10.5.10.51' - else NCMD='' + then NHCMD='ssh root@10.5.10.51' + else NHCMD='' fi # for nip in "${NODE_HOSTS[@]}"; do # if [ "${nip}" = '10.5.10.51' ] && [ ! -z ${LOCAL_SERVICES+x} ]; then isreplhost=true; else isreplhost=false; fi @@ -36,14 +36,14 @@ STATUS() { # done for rcheck in "${REPL_CHECK[@]}"; do - ${NCMD} rm -f ${FOLDER}/test.repl + ${NHCMD} rm -f ${FOLDER}/test.repl daterun=`date +%Y-%m-%d-%H-%M-%S` - if [ "${NCMD}" = "" ]; then + if [ "${NHCMD}" = "" ]; then echo -e "iDS-Node${nid} (${nip})\n${daterun}" > ${FOLDER}/test.repl yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl else - ${NCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl" - yes | ${NCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl" + ${NHCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl" + yes | ${NHCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl" fi done @@ -71,8 +71,7 @@ STATUS() { echo fi nid=1 - for nip in "${NODE_HOSTS[@]}" - do + for nip in "${NODE_HOSTS[@]}"; do if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost' else NCMD="ssh root@${nip}"; LH='' fi @@ -106,8 +105,7 @@ STATUS() { echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}" DIVIDER; echo -e "${idsST[Reset]}" nid=1 - for nip in "${NODE_HOSTS[@]}" - do + for nip in "${NODE_HOSTS[@]}"; do if [ "${nip}" = '10.5.10.51' ] && [ ! -z ${LOCAL_SERVICES+x} ]; then isreplhost=true; else isreplhost=false; fi if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${isreplhost}" = "false" ]; then echo -e " ${idsST[Bold]}${idsCL[LightCyan]}iDS-Node${nid} (${nip})${idsST[Reset]}${idsCL[Default]}" @@ -123,10 +121,10 @@ STATUS() { echo -en " ${REPL_DESC[${rcheck}]}${spc}: " checked=false until [ "${checked}" = "" ]; do - if [ "${NCMD}" = "" ]; then + if [ "${NHCMD}" = "" ]; then checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl` else - checked="`ssh root@10.5.10.51 \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`" + checked="`ssh ${NHCMD} \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`" fi #cdate=`date +%s` if [ "`date +%s`" -gt "$timeout" ]; then @@ -162,17 +160,17 @@ STATUS() { STATUS-CHECK(){ start=`date +%s` if [ "${STATUS_CHECK_EMAIL}" != "" ]; then - if [ ! -z ${LOCAL_SERVICES+x} ]; then NCMD='ssh root@10.5.10.51' - else NCMD=''; fi + if [ ! -z ${LOCAL_SERVICES+x} ]; then NHCMD='ssh root@10.5.10.51' + else NHCMD=''; fi for rcheck in "${REPL_CHECK[@]}"; do - ${NCMD} rm -f ${FOLDER}/test.repl + ${NHCMD} rm -f ${FOLDER}/test.repl daterun=`date +%Y-%m-%d-%H-%M-%S` - if [ "${NCMD}" = "" ]; then + if [ "${NHCMD}" = "" ]; then echo -e "iDS-Node${nid} (${nip})\n${daterun}" > ${FOLDER}/test.repl yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl else - ${NCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl" - yes | ${NCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl" + ${NHCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl" + yes | ${NHCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl" fi done if [ ! -z ${LOCAL_SERVICES+x} ]; then @@ -232,10 +230,10 @@ STATUS-CHECK(){ timeout=`date --date='20 seconds' +%s` checked=false until [ "${checked}" = "" ]; do - if [ "${NCMD}" = "" ]; then + if [ "${NHCMD}" = "" ]; then checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl` else - checked="`ssh root@10.5.10.51 \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`" + checked="`ssh ${NHCMD} \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`" fi if [ "`date +%s`" -gt "$timeout" ]; then timeout=true