Update nodemgmt-scripts.sh

This commit is contained in:
2019-02-07 16:16:49 -06:00
parent 136b4dee52
commit 26f5a0e42b

View File

@@ -22,8 +22,8 @@ STATUS() {
echo echo
declare -i cw; declare -i spc1; declare -i c declare -i cw; declare -i spc1; declare -i c
if [ ! -z ${LOCAL_SERVICES+x} ]; if [ ! -z ${LOCAL_SERVICES+x} ];
then NCMD='ssh root@10.5.10.51' then NHCMD='ssh root@10.5.10.51'
else NCMD='' else NHCMD=''
fi fi
# 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 [ "${nip}" = '10.5.10.51' ] && [ ! -z ${LOCAL_SERVICES+x} ]; then isreplhost=true; else isreplhost=false; fi
@@ -36,14 +36,14 @@ STATUS() {
# done # done
for rcheck in "${REPL_CHECK[@]}"; do 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` 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 echo -e "iDS-Node${nid} (${nip})\n${daterun}" > ${FOLDER}/test.repl
yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl
else else
${NCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl" ${NHCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl"
yes | ${NCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl" yes | ${NHCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl"
fi fi
done done
@@ -71,8 +71,7 @@ STATUS() {
echo echo
fi fi
nid=1 nid=1
for nip in "${NODE_HOSTS[@]}" for nip in "${NODE_HOSTS[@]}"; do
do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost' 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='' else NCMD="ssh root@${nip}"; LH=''
fi fi
@@ -106,8 +105,7 @@ STATUS() {
echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}" echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}"
DIVIDER; echo -e "${idsST[Reset]}" DIVIDER; echo -e "${idsST[Reset]}"
nid=1 nid=1
for nip in "${NODE_HOSTS[@]}" for nip in "${NODE_HOSTS[@]}"; do
do
if [ "${nip}" = '10.5.10.51' ] && [ ! -z ${LOCAL_SERVICES+x} ]; then isreplhost=true; else isreplhost=false; fi 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 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]}" 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}: " echo -en " ${REPL_DESC[${rcheck}]}${spc}: "
checked=false checked=false
until [ "${checked}" = "" ]; do 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` checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl`
else 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 fi
#cdate=`date +%s` #cdate=`date +%s`
if [ "`date +%s`" -gt "$timeout" ]; then if [ "`date +%s`" -gt "$timeout" ]; then
@@ -162,17 +160,17 @@ STATUS() {
STATUS-CHECK(){ STATUS-CHECK(){
start=`date +%s` start=`date +%s`
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then if [ "${STATUS_CHECK_EMAIL}" != "" ]; then
if [ ! -z ${LOCAL_SERVICES+x} ]; then NCMD='ssh root@10.5.10.51' if [ ! -z ${LOCAL_SERVICES+x} ]; then NHCMD='ssh root@10.5.10.51'
else NCMD=''; fi else NHCMD=''; fi
for rcheck in "${REPL_CHECK[@]}"; do 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` 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 echo -e "iDS-Node${nid} (${nip})\n${daterun}" > ${FOLDER}/test.repl
yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl
else else
${NCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl" ${NHCMD} "echo -e \"Status-Check (${NODE_HOSTNAME})\n${daterun}\" > ${FOLDER}/test.repl"
yes | ${NCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl" yes | ${NHCMD} "cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl"
fi fi
done done
if [ ! -z ${LOCAL_SERVICES+x} ]; then if [ ! -z ${LOCAL_SERVICES+x} ]; then
@@ -232,10 +230,10 @@ STATUS-CHECK(){
timeout=`date --date='20 seconds' +%s` timeout=`date --date='20 seconds' +%s`
checked=false checked=false
until [ "${checked}" = "" ]; do 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` checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl`
else 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 fi
if [ "`date +%s`" -gt "$timeout" ]; then if [ "`date +%s`" -gt "$timeout" ]; then
timeout=true timeout=true