From 8058192c6ba3fd91b992974d692c192474054936 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 19 Mar 2023 11:27:30 -0500 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 15528f9b..ab0fd7e7 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -184,11 +184,9 @@ STATUS(){ else toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.down) fi - rm -f ${FOLDER}/${nip}.down; rm -f ${FOLDER}/${nip}.errtime - #if [ "${EMAIL_NOTICE}" != "" ]; then echo "${NM_NODETYPES[$NTYPE]}-Node${nid} is back UP! It was down for $(SHOW_TIME ${toterrtime})\n$(date)" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}-UP" ${EMAIL_NOTICE}; fi + rm -f ${FOLDER}/${nip}.down + rm -f ${FOLDER}/${nip}.errtime SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}-UP" "${NM_NODETYPES[$NTYPE]}-Node${nid} is back UP! It was down for $(SHOW_TIME ${toterrtime})" - echo "$(date) - ${nip} - ${NM_NODETYPES[$NTYPE]}-Node${nid} - Node is back up, it was down for $(SHOW_TIME ${toterrtime})" >> ${LOGFILE} - fi if [ "${ST_ACTION}" != "dockers" ]; then @@ -423,8 +421,15 @@ STATUS(){ checkhost=$(CHECK_HOST ${nip}) if [ "${checkhost}" != "false" ]; then if [ -f ${FOLDER}/${nip}.down ]; then + if [ -f ${FOLDER}/${nip}.errtime ]; then + toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.errtime) + else + toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.down) + fi rm -f ${FOLDER}/${nip}.down - # if [ "${EMAIL_NOTICE}" != "" ]; then echo "${NM_NODETYPES[$NTYPE]}-Node${nid} is back UP!" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}-UP" ${EMAIL_NOTICE}; fi + rm -f ${FOLDER}/${nip}.errtime + SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}-UP" "${NM_NODETYPES[$NTYPE]}-Node${nid} is back UP! It was down for $(SHOW_TIME ${toterrtime})" + fi var2=${NTYPE}_REPL_CHECK[@] # timeout=`date --date='20 seconds' +%s` @@ -652,7 +657,9 @@ CHECK_DOCKER_SERVICES(){ else toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.down) fi - rm -f ${FOLDER}/${nip}.down; rm -f ${FOLDER}/${nip}.errtime + rm -f ${FOLDER}/${nip}.down + rm -f ${FOLDER}/${nip}.errtime + SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}-UP" "${NM_NODETYPES[$NTYPE]}-Node${nid} is back UP! It was down for $(SHOW_TIME ${toterrtime})" fi for docker in "${!dockers}"; do