diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 1ba61f72..001e1e91 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -139,6 +139,35 @@ case "$1" in echo -e "${idsCL[Yellow]}-------------------------------------------------------------${idsCL[Default]}" echo "" ;; + + status-check) + nid=1 + for nip in "${NODE_HOSTS[@]}" + do + if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then + nip='localhost' + NCMD='' + else + NCMD="ssh root@${nip}" + 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}" = "gitea" ]; then SER='Gitea: ' + elif [ "${srvc}" = "haproxy" ]; then SER='HAProxy:' + elif [ "${srvc}" = "keepalived" ]; then SER='Keepalived:' + elif [ "${srvc}" = "maxscale" ]; then SER='MaxScale:' + else SER="${2}" + fi + if [ $(${NCMD} pgrep ${srvc} | wc -l) -lt "1" ]; then + echo "${SER} is down" | mail -s "iDS-Node${nid}-${nip}" 9208839613@vtext.com + fi + done + nid=`expr $nid + 1` + done + ;; set-permissions) nid=1