From 48ed46c8b9abb076684f5243e74848ac7bdb2104 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 4 Jul 2023 16:57:31 -0500 Subject: [PATCH] update --- defaults.inc | 21 ++++++++++++++++++--- inc/sites.inc | 2 +- inc/status.inc | 12 ++++++------ nodemgmt-scripts.sh | 14 +++++++------- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/defaults.inc b/defaults.inc index be8ccb74..52cceecc 100755 --- a/defaults.inc +++ b/defaults.inc @@ -42,12 +42,12 @@ if [ -f ${NM_FOLDER}/defaults.local.inc ]; then unset IFS NODETYPES=$(for k in "${!NM_NODETYPES[@]}"; do echo "${NM_NODETYPES["$k"]} ${k}"; done | sort -f | while read desc nmtype; do echo ${nmtype}; done) - IFS=$'\n' NODE_TYPES=(${NODETYPES}); unset IFS + IFS=$'\n' NM_NODE_TYPES=(${NODETYPES}); unset IFS - # printf "[%s]\n" "${NODE_TYPES[@]}" + # printf "[%s]\n" "${NM_NODE_TYPES[@]}" - for ntype in "${NODE_TYPES[@]}"; do + for ntype in "${NM_NODE_TYPES[@]}"; do arr ${ntype}_HOSTS arr ${ntype}_SERVICES_CHECK arr ${ntype}_DOCKERS_CHECK @@ -108,6 +108,21 @@ if [ -f ${NM_FOLDER}/defaults.local.inc ]; then fi +RUN_NODE_IP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) +for NTYPE in "${NM_NODE_TYPES[@]}"; do + var=${NTYPE}_HOSTS[@] + RUN_NODE_TYPE="" + for nip in "${!var}"; do + if [[ "${RUN_NODE_IP}" == *"${nip}"* ]]; then + RUN_NODE_TYPE=${NTYPE}; + break 2 + fi + done +done + +echo "RUN_NODE_IP: $RUN_NODE_IP" +echo "RUN_NODE_TYPE: $RUN_NODE_TYPE" + declare -A NM_SRVCOPTS NM_SRVCOPTS['status']='Status' NM_SRVCOPTS['start']='Start' diff --git a/inc/sites.inc b/inc/sites.inc index db139077..71e87944 100755 --- a/inc/sites.inc +++ b/inc/sites.inc @@ -511,7 +511,7 @@ SITEINFO(){ cw_spc7=15 dl=110 MIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do var=${NTYPE}_HOSTS[@] NODE_TYPE="" for nip in "${!var}"; do diff --git a/inc/status.inc b/inc/status.inc index 5b43c574..e97ed2b8 100755 --- a/inc/status.inc +++ b/inc/status.inc @@ -16,7 +16,7 @@ STATUS(){ if [ "${ST_ACTION}" != "check" ]; then echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}" fi - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do PH=${NTYPE}_HOSTS[0] if [ ! -f ${NM_FOLDER}/${!PH}.down ]; then PH_CMD="ssh root@${!PH}" @@ -115,7 +115,7 @@ STATUS(){ fi ######################## - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do nid=1 dockers=${NTYPE}_DOCKERS_CHECK[@] @@ -444,7 +444,7 @@ STATUS(){ DIVIDER; echo -e "${idsST[Reset]}" echo -en " ${idsCL[LightCyan]}Starting processes to collect/monitor replication status : " fi - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do PH=${NTYPE}_HOSTS[0] PH_CMD="ssh root@${!PH}" var=${NTYPE}_REPL_CHECK[@] @@ -464,7 +464,7 @@ STATUS(){ done [ "${ST_ACTION}" != "check" ] && echo -e "${idsCL[Green]}Done${idsCL[Default]}\n" - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do PH=${NTYPE}_HOSTS[0] PH_CMD="ssh root@${!PH}" var=${NTYPE}_REPL_CHECK[@] @@ -536,7 +536,7 @@ STATUS(){ #NHCMD="ssh root@${MYSQL_HOSTS[0]}" #LBHCMD="ssh root@${LB_HOSTS[0]}" #WHCMD="ssh root@${WEB_HOSTS[0]}" - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do PH=${NTYPE}_HOSTS[0] if [ ! -f ${NM_FOLDER}/${!PH}.down ]; then PH_CMD="ssh root@${!PH}" @@ -570,7 +570,7 @@ STATUS(){ #if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "freespace" ]; then if [ "${ST_ACTION}" = "freespace" ]; then if [ "${ST_ACTION}" != "repl" ] && [ "${ST_ACTION}" != "services" ]; then - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do if [ "${ST_ACTION}" != "check" ]; then echo -e "${idsST[Bold]}"; DIVIDER echo -e "${idsCL[Yellow]} ${NM_NODETYPES[$NTYPE]}-Node Free Space Scan${idsCL[Default]}" diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 181fdd99..87c5591f 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -14,7 +14,7 @@ source /opt/idssys/nodemgmt/inc/sites.inc CHECK_DOCKER_SERVICES(){ - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do dockers=${NTYPE}_DOCKERS_CHECK[@] hosts=${NTYPE}_HOSTS[@] @@ -379,7 +379,7 @@ SERVICE(){ else if [ "${4}" != "all" ]; then - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do var=${NTYPE}_HOSTS[@] NODE_TYPE="" for nip in "${!var}"; do @@ -391,7 +391,7 @@ SERVICE(){ done if [ "${NODE_TYPE}" == "" ] && [ ${#TSI} != 0 ]; then - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do var=${NTYPE}_HOSTS[@] for nip in "${!var}"; do if [[ "${TSIP}" == *"${nip}"* ]]; then @@ -407,11 +407,11 @@ SERVICE(){ NT_HOST=${NODE_TYPE}_HOSTS[0] NTS=("${NODE_TYPE}"); else - NTS=(${NODE_TYPES[*]}) + NTS=(${NM_NODE_TYPES[*]}) fi else - NTS=(${NODE_TYPES[*]}) + NTS=(${NM_NODE_TYPES[*]}) fi # if [ "${NODE_TYPE}" == "" ]; then @@ -797,7 +797,7 @@ NODEUPDATE() { nmdiv=$(ssh -tq root@${nmip} ls -l --time-style=+%s ${NM_FOLDER}/defaults.local.inc | cut -d ' ' -f 6) - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do nid=1 var=${NTYPE}_HOSTS[@] for nip in "${!var}"; do @@ -1009,7 +1009,7 @@ UPDATE_DYNDNS(){ RUN_COMMAND(){ echo "${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14}" - for NTYPE in "${NODE_TYPES[@]}"; do + for NTYPE in "${NM_NODE_TYPES[@]}"; do echo -e "${idsST[Bold]}"; DIVIDER echo -e "${idsCL[Yellow]} ${NM_NODETYPES[$NTYPE]}-Nodes to run command { \`${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14}\` }${idsCL[Default]}" DIVIDER; echo -e "${idsST[Reset]}"