Update nodemgmt-scripts.sh

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

View File

@@ -156,77 +156,79 @@ STATUS(){
fi fi
var2=${NTYPE}_SERVICES_CHECK[@] var2=${NTYPE}_SERVICES_CHECK[@]
for srvc in "${!var2}"; do for srvc in "${!var2}"; do
if [ "${ST_ACTION}" != "check" ]; then if [ "${NIP}" != "10.5.10.122" ] && [ ${srvc} != "gitea" ]; then
c=0; cw=22; spc='' if [ "${ST_ACTION}" != "check" ]; then
spc1=${cw}-${#NM_SERVICES[${srvc}]} c=0; cw=22; spc=''
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done spc1=${cw}-${#NM_SERVICES[${srvc}]}
echo -en " ${NM_SERVICES[${srvc}]}$spc: " until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
fi echo -en " ${NM_SERVICES[${srvc}]}$spc: "
fi
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
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
# fi
else
errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
if [ $errtime -gt ${RENOTIFY} ]; then
if [ ! -f ${FOLDER}/${nip}-${srvc}.errtime ]; then
mv ${FOLDER}/${nip}-${srvc}.down ${FOLDER}/${nip}-${srvc}.errtime
fi
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime)
if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsCL[Red]}Not running for $(SHOW_TIME ${toterrtime})${idsCL[Default]}"
fi
# if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} has been down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
touch ${FOLDER}/${nip}-${srvc}.down
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
touch ${FOLDER}/${nip}-${srvc}.down
fi fi
else else
errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down) if [ "${ST_ACTION}" != "check" ]; then
if [ $errtime -gt ${RENOTIFY} ]; then echo -e "${idsCL[Green]}Running${idsCL[Default]}"
if [ ! -f ${FOLDER}/${nip}-${srvc}.errtime ]; then
mv ${FOLDER}/${nip}-${srvc}.down ${FOLDER}/${nip}-${srvc}.errtime
fi
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime)
if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsCL[Red]}Not running for $(SHOW_TIME ${toterrtime})${idsCL[Default]}"
fi
# if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} has been down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
touch ${FOLDER}/${nip}-${srvc}.down
fi fi
fi if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then
else if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then
if [ "${ST_ACTION}" != "check" ]; then toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime)
echo -e "${idsCL[Green]}Running${idsCL[Default]}" else
fi toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then fi
if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is back UP! It was down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime) rm -f ${FOLDER}/${nip}-${srvc}.down
else rm -f ${FOLDER}/${nip}-${srvc}.errtime
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
fi fi
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_SERVICES[${srvc}]} is back UP! 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}.errtime
fi fi
fi fi
done done