diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 88e9c21b..1c39e236 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -117,60 +117,25 @@ case "$1" in NCMD="ssh root@${nip}" fi - - if [ $(${NCMD} pgrep haproxy | wc -l) -gt "0" ]; then - SER_HAP="${idsCL[Green]}Running${idsCL[Default]}" - else SER_HAP="${idsCL[Red]}Not Running${idsCL[Default]}" - fi - if [ $(${NCMD} pgrep nginx | wc -l) -gt "0" ]; then - SER_NGINX="${idsCL[Green]}Running${idsCL[Default]}" - else SER_NGINX="${idsCL[Red]}Not Running${idsCL[Default]}" - fi - if [ $(${NCMD} pgrep keepalived | wc -l) -gt "0" ]; then - SER_KA="${idsCL[Green]}Running${idsCL[Default]}" - else SER_KA="${idsCL[Red]}Not Running${idsCL[Default]}" - fi - if [ $(${NCMD} pgrep gogs | wc -l) -gt "0" ]; then - SER_GOGS="${idsCL[Green]}Running${idsCL[Default]}" - else SER_GOGS="${idsCL[Red]}Not Running${idsCL[Default]}" - fi - if [ $(${NCMD} pgrep maxscale | wc -l) -gt "0" ]; then - SER_MS="${idsCL[Green]}Running${idsCL[Default]}" - else SER_MS="${idsCL[Red]}Not Running${idsCL[Default]}" - fi - echo -e "${idsCL[Yellow]}-------------------------------------------------------------${idsCL[Default]}" echo -e "Node hostname: ${nip}" - echo -en "MySQL: " - if [ $(${NCMD} pgrep mysql | wc -l) -gt "0" ]; then - echo -e "${idsCL[Green]}Running${idsCL[Default]}" - else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" - fi - echo -en "NGINX: " - if [ $(${NCMD} pgrep nginx | wc -l) -gt "0" ]; then - echo -e "${idsCL[Green]}Running${idsCL[Default]}" - else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" - fi - echo -en "Gogs: " - if [ $(${NCMD} pgrep gogs | wc -l) -gt "0" ]; then - echo -e "${idsCL[Green]}Running${idsCL[Default]}" - else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" - fi - echo -en "HAProxy: " - if [ $(${NCMD} pgrep haproxy | wc -l) -gt "0" ]; then - echo -e "${idsCL[Green]}Running${idsCL[Default]}" - else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" - fi - echo -en "Keepalived: " - if [ $(${NCMD} pgrep keepalived | wc -l) -gt "0" ]; then - echo -e "${idsCL[Green]}Running${idsCL[Default]}" - else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" - fi - echo -en "MaxScale: " - if [ $(${NCMD} pgrep maxscale | wc -l) -gt "0" ]; then - echo -e "${idsCL[Green]}Running${idsCL[Default]}" - else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" - fi + + for srvc in "${NODE_SERVICES[@]}" + do + if [ "${srvc}" = "mysql" ]; then SER='MySQL' + elif [ "${srvc}" = "nginx" ]; then SER='NGINX' + elif [ "${srvc}" = "gogs" ]; then SER='Gogs' + elif [ "${srvc}" = "haproxy" ]; then SER='HAProxy' + elif [ "${srvc}" = "keepalived" ]; then SER='Keepalived' + elif [ "${srvc}" = "maxscale" ]; then SER='MaxScale' + else SER="${2}" + fi + echo -en "${SER}: " + if [ $(${NCMD} pgrep ${srvc} | wc -l) -gt "0" ]; then + echo -e "${idsCL[Green]}Running${idsCL[Default]}" + else echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" + fi + done nid=`expr $nid + 1` done