Update nodemgmt-scripts.sh

This commit is contained in:
2019-02-07 12:41:29 -06:00
parent 8204a17e4a
commit 343fa07e9f

View File

@@ -86,7 +86,7 @@ STATUS() {
nid=`expr $nid + 1`
done
echo -e "${idsST[Bold]}"; DIVIDER
echo -e "${idsCL[Yellow]} Replication Status to Other Nodes${idsCL[Default]}"
echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}"
DIVIDER; echo -e "${idsST[Reset]}"
timeout=`date --date='30 seconds' +%s`
nid=1
@@ -110,16 +110,13 @@ STATUS() {
checked="`ssh root@10.5.10.51 \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`"
fi
if [ "`date +%s`" -gt "$timeout" ]; then
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then
echo "Timeout occurred in waiting for replication between nodes." | mail -s "Status-Check" ${STATUS_CHECK_EMAIL}
fi
timeout=true
touch ${FOLDER}/${nip}-${rcheck}.down
break
fi
done
if [ "${timeout}" = "true" ]; then
echo -e "${idsCL[Red]}Timeout${idsCL[Default]}"
touch ${FOLDER}/${nip}-${rcheck}.down
else
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
rm -f ${FOLDER}/${nip}-${rcheck}.down
@@ -141,14 +138,15 @@ STATUS-CHECK(){
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then
if [ ! -z ${LOCAL_SERVICES+x} ]; then NCMD='ssh root@10.5.10.51'
else NCMD=''; fi
for nip in "${NODE_HOSTS[@]}"; do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then
for rcheck in "${REPL_CHECK[@]}"; do
${NCMD} rm -f ${FOLDER}/test.repl
daterun=`date +%Y-%m-%d-%H-%M-%S`
${NCMD} echo -e "iDS-Node${nid} (${nip})\n${daterun}" > ${FOLDER}/test.repl
${NCMD} yes | cp -rfH ${FOLDER}/test.repl ${REPL_CHECKS[${rcheck}]}/test.repl
done
for rcheck in "${REPL_CHECK[@]}"; do
${NCMD} rm -f ${FOLDER}/test.repl
daterun=`date +%Y-%m-%d-%H-%M-%S`
if [ "${NCMD}" = "" ]; 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"
fi
done
if [ ! -z ${LOCAL_SERVICES+x} ]; then
@@ -186,22 +184,35 @@ STATUS-CHECK(){
fi
#REPLICATION CHECK
timeout=`date --date='30 seconds' +%s`
nid=1
for nip in "${NODE_HOSTS[@]}"
do
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]]; then
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
for rcheck in "${REPL_CHECK[@]}"
do
checked=false
until [ "${checked}" = "" ]; do
checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl`
if [ "${NCMD}" = "" ]; 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\"`"
fi
if [ "`date +%s`" -gt "$timeout" ]; then
echo "Timeout occurred in waiting for replication between nodes." | mail -s "Status-Check" ${STATUS_CHECK_EMAIL}
timeout=true
break
fi
done
if [ "${timeout}" = "true" ]; then
touch ${FOLDER}/${nip}-${rcheck}.down
echo "Timeout occurred in waiting for replication between primary node and iDS-Node${nid} (${nip})." | mail -s "Status-Check" ${STATUS_CHECK_EMAIL}
else
rm -f ${FOLDER}/${nip}-${rcheck}.down
fi
done
echo
fi
nid=`expr $nid + 1`
done
fi
}