Update nodemgmt-scripts.sh
This commit is contained in:
@@ -133,15 +133,15 @@ STATUS(){
|
|||||||
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
|
if [[ $(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) == *"${nip}"* ]]; then NCMD=''; LH='- localhost'
|
||||||
else NCMD="ssh root@${nip}"; LH=''
|
else NCMD="ssh root@${nip}"; LH=''
|
||||||
fi
|
fi
|
||||||
if [ "${ST_ACTION}" != "check" ]; then
|
|
||||||
uptime=`${NCMD} uptime -p`
|
|
||||||
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_NODETYPES[$NTYPE]}-Node${nid} (${nip})${idsST[Reset]}${idsCL[LightCyan]} - ${uptime} ${idsCL[LightYello]}${LH}${idsCL[Default]}"
|
|
||||||
DIVIDER false green
|
|
||||||
fi
|
|
||||||
if [ "${NCMD}" != "" ]; then
|
if [ "${NCMD}" != "" ]; then
|
||||||
checkhost=$(CHECK_HOST ${nip})
|
checkhost=$(CHECK_HOST ${nip})
|
||||||
fi
|
fi
|
||||||
if [ "${checkhost}" != "false" ]; then
|
if [ "${checkhost}" != "false" ]; then
|
||||||
|
if [ "${ST_ACTION}" != "check" ]; then
|
||||||
|
uptime=`${NCMD} uptime -p`
|
||||||
|
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_NODETYPES[$NTYPE]}-Node${nid} (${nip})${idsST[Reset]}${idsCL[LightCyan]} - ${uptime} ${idsCL[LightYello]}${LH}${idsCL[Default]}"
|
||||||
|
DIVIDER false green
|
||||||
|
fi
|
||||||
if [ -f ${FOLDER}/${nip}.down ]; then
|
if [ -f ${FOLDER}/${nip}.down ]; then
|
||||||
if [ -f ${FOLDER}/${nip}.errtime ]; then
|
if [ -f ${FOLDER}/${nip}.errtime ]; then
|
||||||
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.errtime)
|
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.errtime)
|
||||||
@@ -228,21 +228,17 @@ STATUS(){
|
|||||||
else
|
else
|
||||||
if [ ! -f ${FOLDER}/${nip}.down ]; then
|
if [ ! -f ${FOLDER}/${nip}.down ]; then
|
||||||
touch ${FOLDER}/${nip}.down
|
touch ${FOLDER}/${nip}.down
|
||||||
|
if [ ! -f ${FOLDER}/${nip}.errtime ]; then
|
||||||
|
touch ${FOLDER}/${nip}.errtime
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ "${ST_ACTION}" != "check" ]; then
|
||||||
|
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.errtime)
|
||||||
|
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NM_NODETYPES[$NTYPE]}-Node${nid} (${nip})${idsST[Reset]}${idsCL[LightCyan]} - Node has been down for $(SHOW_TIME ${toterrtime}) ${idsCL[LightYello]}${LH}${idsCL[Default]}"
|
||||||
fi
|
fi
|
||||||
errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.down)
|
errtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}.down)
|
||||||
if [ $errtime -gt ${RENOTIFY} ]; then
|
if [ $errtime -gt ${RENOTIFY} ] && [ "${STATUS_CHECK_EMAIL}" != "" ]; then
|
||||||
if [ ! -f ${FOLDER}/${nip}.errtime ]; then
|
echo "${NM_NODETYPES[$NTYPE]}-Node${nid} has been down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}
|
||||||
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
|
|
||||||
if [ "${STATUS_CHECK_EMAIL}" != "" ]; then echo "${NM_NODETYPES[$NTYPE]}-Node${nid} has been down for $(SHOW_TIME ${toterrtime})" | mail -s "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" ${STATUS_CHECK_EMAIL}; fi
|
|
||||||
else
|
|
||||||
if [ "${ST_ACTION}" != "check" ]; then
|
|
||||||
echo -e "${idsCL[Red]}Node is Down!${idsCL[Default]}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "${ST_ACTION}" != "check" ]; then echo; fi
|
if [ "${ST_ACTION}" != "check" ]; then echo; fi
|
||||||
|
|||||||
Reference in New Issue
Block a user