Update nodemgmt-scripts.sh
This commit is contained in:
@@ -743,105 +743,135 @@ MAINTENANCE_MODE(){
|
||||
PRI_CW=40
|
||||
DV_LEN=70
|
||||
declare -i cw; declare -i spc1; declare -i c
|
||||
item_number=1
|
||||
until [ "${choice^^}" = "E" ]; do
|
||||
item_number=1
|
||||
|
||||
for NTYPE in "${ntypesel[@]}"; do
|
||||
srvcs=${NTYPE}_SERVICES_CHECK[@];
|
||||
dockers=${NTYPE}_DOCKERS_CHECK[@]
|
||||
hosts=${NTYPE}_HOSTS[@]
|
||||
repls=${NTYPE}_REPL_CHECK[@]
|
||||
for NTYPE in "${ntypesel[@]}"; do
|
||||
srvcs=${NTYPE}_SERVICES_CHECK[@];
|
||||
dockers=${NTYPE}_DOCKERS_CHECK[@]
|
||||
hosts=${NTYPE}_HOSTS[@]
|
||||
repls=${NTYPE}_REPL_CHECK[@]
|
||||
|
||||
if ([[ ! -v ${NTYPE}_DOCKERS_CHECK ]] && [ "${MM_ACTION}" == "dockers" ]) || ([ "${NM_SERVICES_CHECK[${NTYPE}]}" == "" ] && [ "${MM_ACTION}" == "services" ]); then
|
||||
GOFORCHECK=false;
|
||||
else
|
||||
GOFORCHECK=true;
|
||||
fi
|
||||
|
||||
if [ ${GOFORCHECK} = true ]; then
|
||||
|
||||
echo -en "${idsST[Bold]}"; DIVIDER . lightYellow ${DV_LEN}
|
||||
echo -e "${idsCL[LightYellow]} ${NM_NODETYPES[$NTYPE]}-Node Status Checks${idsCL[Default]}"
|
||||
DIVIDER . lightYellow ${DV_LEN}; echo -en "${idsST[Reset]}"
|
||||
|
||||
for nip in "${!hosts}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
MSG="${NM_HOSTNAMES[${nip}]} [${nip}]"
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} + 4 - ${#MSG}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsST[Bold]}${idsCL[LightCyan]}${MSG}${idsST[Reset]}${spc}${idsCL[Default]}: "
|
||||
|
||||
echo -e "${idsCL[LightGreen]}here${idsCL[Default]}"
|
||||
((item_number++))
|
||||
DIVIDER false lightCyan ${DV_LEN}
|
||||
|
||||
|
||||
########################
|
||||
## SERVICES CHECK
|
||||
########################
|
||||
if [ "${MM_ACTION}" != "dockers" ] && [ "${NM_SERVICES_CHECK[${NTYPE}]}" != "" ]; then
|
||||
echo -e "${idsCL[Green]} System Service(s)${idsCL[Default]}"
|
||||
DIVIDER . green ${DV_LEN}
|
||||
|
||||
for srvc in "${!srvcs}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} - ${#NM_SERVICE_DESC[${srvc}]}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsCL[White]}${NM_SERVICE_DESC[${srvc}]}${spc}${idsCL[Default]}: "
|
||||
|
||||
echo -e "${idsCL[LightGreen]}here${idsCL[Default]}"
|
||||
((item_number++))
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
########################
|
||||
## DOCKER CHECK
|
||||
########################
|
||||
if [[ -v ${NTYPE}_DOCKERS_CHECK ]] && [ "${MM_ACTION}" != "services" ]; then
|
||||
[ "${MM_ACTION}" == "" ] && [ "${NM_SERVICES_CHECK[${NTYPE}]}" != "" ] && echo
|
||||
echo -e "${idsCL[Green]} Docker Service(s)${idsCL[Default]}"
|
||||
DIVIDER . green ${DV_LEN}
|
||||
|
||||
for docker in "${!dockers}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} - ${#NM_DOCKER_DESC[${docker}]}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsCL[White]}${NM_DOCKER_DESC[${docker}]}$spc${idsCL[Default]}: "
|
||||
|
||||
echo -e "${idsCL[LightGreen]}here${idsCL[Default]}"
|
||||
((item_number++))
|
||||
done
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
########################
|
||||
## REPLICATION CHECK
|
||||
########################
|
||||
|
||||
if ([ "${STATUS_ACTION}" == "repl" ] || [ "${STATUS_ACTION}" == "" ]) && [ ! -z ${!repls+x} ]; then
|
||||
if [ "${MM_ACTION}" != "check" ]; then
|
||||
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${NM_NODETYPES[${NTYPE}]} Replication Check(s)${idsST[Reset]}${idsCL[Default]}"
|
||||
DIVIDER . lightCyan ${DV_LEN}
|
||||
if ([[ ! -v ${NTYPE}_DOCKERS_CHECK ]] && [ "${MM_ACTION}" == "dockers" ]) || ([ "${NM_SERVICES_CHECK[${NTYPE}]}" == "" ] && [ "${MM_ACTION}" == "services" ]); then
|
||||
GOFORCHECK=false;
|
||||
else
|
||||
GOFORCHECK=true;
|
||||
fi
|
||||
PH=${NTYPE}_HOSTS[0]
|
||||
PH_CMD="ssh root@${!PH}"
|
||||
var2=${NTYPE}_HOSTS[@]
|
||||
for nip in "${!hosts}"; do
|
||||
echo -e " ${idsCL[Green]}${NM_HOSTNAMES[${!PH}]}[${!PH}] <--> ${idsST[Bold]}${NM_HOSTNAMES[${nip}]}[${nip}]${idsST[Reset]}${idsCL[Default]}"
|
||||
DIVIDER . green ${DV_LEN}
|
||||
for rcheck in "${!repls}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} - ${#NM_REPL_DESC[${rcheck}]}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsCL[White]}${NM_REPL_DESC[${rcheck}]}${spc}${idsCL[Default]}: "
|
||||
|
||||
echo -e "${idsCL[LightGreen]}here${idsCL[Default]}"
|
||||
|
||||
if [ ${GOFORCHECK} = true ]; then
|
||||
|
||||
echo -en "${idsST[Bold]}"; DIVIDER . lightYellow ${DV_LEN}
|
||||
echo -e "${idsCL[LightYellow]} ${NM_NODETYPES[$NTYPE]}-Node Status Checks${idsCL[Default]}"
|
||||
DIVIDER . lightYellow ${DV_LEN}; echo -en "${idsST[Reset]}"
|
||||
|
||||
for nip in "${!hosts}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
MSG="${NM_HOSTNAMES[${nip}]} [${nip}]"
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} + 4 - ${#MSG}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsST[Bold]}${idsCL[LightCyan]}${MSG}${idsST[Reset]}${spc}${idsCL[Default]}: "
|
||||
|
||||
if [ "${choice}" -gt 0 ] 2>/dev/null && [ ${item_number} -eq ${choice} ]; then
|
||||
[ ! -f ${NM_TMPFOLDER}/${nip}.disable ] && touch ${NM_TMPFOLDER}/${nip}.disable || rm -f ${NM_TMPFOLDER}/${nip}.disable
|
||||
fi
|
||||
[ -f ${NM_TMPFOLDER}/${nip}.disable ] && dstatus="${idsCL[LightRed]}OFF" || dstatus="${idsCL[Green]}ON"
|
||||
|
||||
echo -e "${dstatus}${idsCL[Default]}"
|
||||
((item_number++))
|
||||
DIVIDER false lightCyan ${DV_LEN}
|
||||
|
||||
|
||||
########################
|
||||
## SERVICES CHECK
|
||||
########################
|
||||
if [ "${MM_ACTION}" != "dockers" ] && [ "${NM_SERVICES_CHECK[${NTYPE}]}" != "" ]; then
|
||||
echo -e "${idsCL[Green]} System Service(s)${idsCL[Default]}"
|
||||
DIVIDER . green ${DV_LEN}
|
||||
|
||||
for srvc in "${!srvcs}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} - ${#NM_SERVICE_DESC[${srvc}]}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsCL[White]}${NM_SERVICE_DESC[${srvc}]}${spc}${idsCL[Default]}: "
|
||||
|
||||
if [ "${choice}" -gt 0 ] 2>/dev/null && [ ${item_number} -eq ${choice} ]; then
|
||||
[ ! -f ${NM_TMPFOLDER}/${nip}~${srvc}.disable ] && touch ${NM_TMPFOLDER}/${nip}~${srvc}.disable || rm -f ${NM_TMPFOLDER}/${nip}~${srvc}.disable
|
||||
fi
|
||||
[ -f ${NM_TMPFOLDER}/${nip}~${srvc}.disable ] && dstatus="${idsCL[LightRed]}OFF" || dstatus="${idsCL[Green]}ON"
|
||||
|
||||
echo -e "${dstatus}${idsCL[Default]}"
|
||||
((item_number++))
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
########################
|
||||
## DOCKER CHECK
|
||||
########################
|
||||
if [[ -v ${NTYPE}_DOCKERS_CHECK ]] && [ "${MM_ACTION}" != "services" ]; then
|
||||
[ "${MM_ACTION}" == "" ] && [ "${NM_SERVICES_CHECK[${NTYPE}]}" != "" ] && echo
|
||||
echo -e "${idsCL[Green]} Docker Service(s)${idsCL[Default]}"
|
||||
DIVIDER . green ${DV_LEN}
|
||||
|
||||
for docker in "${!dockers}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} - ${#NM_DOCKER_DESC[${docker}]}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsCL[White]}${NM_DOCKER_DESC[${docker}]}$spc${idsCL[Default]}: "
|
||||
|
||||
if [ "${choice}" -gt 0 ] 2>/dev/null && [ ${item_number} -eq ${choice} ]; then
|
||||
[ ! -f ${NM_TMPFOLDER}/${nip}~${docker}.disable ] && touch ${NM_TMPFOLDER}/${nip}~${docker}.disable || rm -f ${NM_TMPFOLDER}/${nip}~${docker}.disable
|
||||
fi
|
||||
[ -f ${NM_TMPFOLDER}/${nip}~${docker}.disable ] && dstatus="${idsCL[LightRed]}OFF" || dstatus="${idsCL[Green]}ON"
|
||||
|
||||
echo -e "${dstatus}${idsCL[Default]}"
|
||||
((item_number++))
|
||||
done
|
||||
fi
|
||||
echo
|
||||
done
|
||||
echo
|
||||
done
|
||||
fi
|
||||
echo
|
||||
|
||||
fi
|
||||
|
||||
########################
|
||||
## REPLICATION CHECK
|
||||
########################
|
||||
|
||||
if ([ "${STATUS_ACTION}" == "repl" ] || [ "${STATUS_ACTION}" == "" ]) && [ ! -z ${!repls+x} ]; then
|
||||
if [ "${MM_ACTION}" != "check" ]; then
|
||||
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${NM_NODETYPES[${NTYPE}]} Replication Check(s)${idsST[Reset]}${idsCL[Default]}"
|
||||
DIVIDER . lightCyan ${DV_LEN}
|
||||
fi
|
||||
PH=${NTYPE}_HOSTS[0]
|
||||
PH_CMD="ssh root@${!PH}"
|
||||
var2=${NTYPE}_HOSTS[@]
|
||||
for nip in "${!hosts}"; do
|
||||
echo -e " ${idsCL[Green]}${NM_HOSTNAMES[${!PH}]}[${!PH}] <--> ${idsST[Bold]}${NM_HOSTNAMES[${nip}]}[${nip}]${idsST[Reset]}${idsCL[Default]}"
|
||||
DIVIDER . green ${DV_LEN}
|
||||
for rcheck in "${!repls}"; do
|
||||
if [ ${item_number} -lt 10 ]; then isel=" ${item_number})"; elif [ ${item_number} -lt 100 ]; then isel=" ${item_number})"; else isel=" ${item_number})"; fi
|
||||
c=0; spc=''; spc1=`expr ${PRI_CW} - ${#NM_REPL_DESC[${rcheck}]}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
echo -en "${idsCL[LightYellow]}${isel} ${idsCL[White]}${NM_REPL_DESC[${rcheck}]}${spc}${idsCL[Default]}: "
|
||||
|
||||
if [ "${choice}" -gt 0 ] 2>/dev/null && [ ${item_number} -eq ${choice} ]; then
|
||||
[ ! -f ${NM_TMPFOLDER}/${nip}~${rcheck}.repl.disable ] && touch ${NM_TMPFOLDER}/${nip}~${rcheck}.repl.disable || rm -f ${NM_TMPFOLDER}/${nip}~${rcheck}.repl.disable
|
||||
fi
|
||||
[ -f ${NM_TMPFOLDER}/${nip}~${rcheck}.repl.disable ] && dstatus="${idsCL[LightRed]}OFF" || dstatus="${idsCL[Green]}ON"
|
||||
|
||||
echo -e "${dstatus}${idsCL[Default]}"
|
||||
((item_number++))
|
||||
done
|
||||
echo
|
||||
done
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
||||
echo -en "\n\033[K${idsCL[LightCyan]}Enter # to change notifications [${idsCL[Default]}(${idsCL[LightYellow]}E${idsCL[Default]})xit${idsCL[LightCyan]}] : ${idsCL[Default]}"
|
||||
read -n 1 choice
|
||||
[ "${choice^^}" == "E" ] && break
|
||||
|
||||
done
|
||||
|
||||
echo
|
||||
|
||||
}
|
||||
|
||||
SETUPSSH(){
|
||||
|
||||
Reference in New Issue
Block a user