Update nodemgmt-scripts.sh

This commit is contained in:
2021-01-16 11:07:42 -06:00
parent c4dd3a4fbf
commit d47677228c

View File

@@ -156,6 +156,7 @@ STATUS(){
fi fi
var2=${NTYPE}_SERVICES_CHECK[@] var2=${NTYPE}_SERVICES_CHECK[@]
for srvc in "${!var2}"; do for srvc in "${!var2}"; do
if [ "${NIP}" != "10.5.10.122" ] && [ ${srvc} != "gitea" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
c=0; cw=22; spc='' c=0; cw=22; spc=''
spc1=${cw}-${#NM_SERVICES[${srvc}]} spc1=${cw}-${#NM_SERVICES[${srvc}]}
@@ -165,41 +166,41 @@ STATUS(){
if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then
if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then
if [ "${srvc}" == "gitea" ]; then # if [ "${srvc}" == "gitea" ]; then
if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then # if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then
SERVICE gitea stop q # SERVICE gitea stop q
SET-PERMISSIONS gitea q # SET-PERMISSIONS gitea q
SERVICE gitea start q # SERVICE gitea start q
fi # fi
if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then # if [ "$(${NCMD} systemctl is-active ${srvc})" != "active" ]; then
if [ "${ST_ACTION}" != "check" ]; then # if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsCL[Red]}Not Running - could not fix${idsCL[Default]}" # echo -e "${idsCL[Red]}Not Running - could not fix${idsCL[Default]}"
fi # fi
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down. Could not fix." | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi # if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down. Could not fix." | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
touch ${FOLDER}/${nip}-${srvc}.down # touch ${FOLDER}/${nip}-${srvc}.down
else # else
if [ "${ST_ACTION}" != "check" ]; then # if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsCL[Green]}Running - FIXED${idsCL[Default]}" # echo -e "${idsCL[Green]}Running - FIXED${idsCL[Default]}"
fi # fi
if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then # if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then
if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then # if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime) # toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime)
else # else
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down) # toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
fi # fi
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is back UP! (!!FIXED!!) It was down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi # if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is back UP! (!!FIXED!!) It was down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
rm -f ${FOLDER}/${nip}-${srvc}.down # rm -f ${FOLDER}/${nip}-${srvc}.down
rm -f ${FOLDER}/${nip}-${srvc}.errtime # rm -f ${FOLDER}/${nip}-${srvc}.errtime
fi # fi
fi # fi
else # else
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
fi fi
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is down" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
touch ${FOLDER}/${nip}-${srvc}.down touch ${FOLDER}/${nip}-${srvc}.down
fi # fi
else else
errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down) errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
if [ $errtime -gt ${RENOTIFY} ]; then if [ $errtime -gt ${RENOTIFY} ]; then
@@ -229,6 +230,7 @@ STATUS(){
rm -f ${FOLDER}/${nip}-${srvc}.errtime rm -f ${FOLDER}/${nip}-${srvc}.errtime
fi fi
fi fi
fi
done done
else else
if [ ! -f ${FOLDER}/${nip}.down ]; then if [ ! -f ${FOLDER}/${nip}.down ]; then