From 1f57455f67e245dd8d4bb41adef37f5c45aaad03 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 8 Feb 2019 00:15:05 -0600 Subject: [PATCH] Update nodemgmt-scripts.sh --- nodemgmt-scripts.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/nodemgmt-scripts.sh b/nodemgmt-scripts.sh index 26add2dd..6c954b33 100755 --- a/nodemgmt-scripts.sh +++ b/nodemgmt-scripts.sh @@ -144,15 +144,28 @@ STATUS(){ echo -e "${idsCL[Green]}Running${idsCL[Default]}" fi if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then - echo "${NM_SERVICES[${srvc}]} is back UP!" | mail -s "iDS-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL} + toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime) + echo "${NM_SERVICES[${srvc}]} is back UP! It was down for $(SHOW_TIME ${toterrtime})" | mail -s "iDS-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL} rm -f ${FOLDER}/${nip}-${srvc}.down rm -f ${FOLDER}/${nip}-${srvc}.errtime fi fi done else - if [ "${ST_ACTION}" != "check" ]; then - echo -e "${idsCL[Red]}Node is Down!${idsCL[Default]}" + errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.down) + if [ $errtime -gt ${RENOTIFY} ]; then + if [ ! -f ${FOLDER}/${nip}.errtime ]; then + mv ${FOLDER}/${nip}.down ${FOLDER}/${nip}.errtime + fi + toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.errtime) + if [ "${ST_ACTION}" != "check" ]; then + echo -e "${idsCL[Red]}Node has been down for $(SHOW_TIME ${toterrtime})${idsCL[Default]}" + fi + echo "iDS-Node${nid} has been down for $(SHOW_TIME ${toterrtime})" | mail -s "iDS-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL} + else + if [ "${ST_ACTION}" != "check" ]; then + echo -e "${idsCL[Red]}Node is Down!${idsCL[Default]}" + fi fi touch ${FOLDER}/${nip}.down fi