This commit is contained in:
2019-02-07 14:05:08 -06:00
parent e5a0dbfe80
commit 89e6ea1fa8
2 changed files with 54 additions and 50 deletions

View File

@@ -113,3 +113,10 @@ CERT-CHECK(){
fi
}
CHECK_HOST(){
ping -c 3 ${1} > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo false
fi
}

View File

@@ -53,17 +53,6 @@ STATUS() {
lip=$(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1)
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}${NODE_HOSTNAME} (${lip})${idsST[Reset]}${idsCL[LightCyan]} - localhost${idsCL[Default]}"
DIVIDER false green
ping -c 3 $SERVERIP > /dev/null 2>&1
if [ $? -ne 0 ]
then
# Use your favorite mailer here:
mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null
fiping -c 3 $SERVERIP > /dev/null 2>&1
if [ $? -ne 0 ]
then
# Use your favorite mailer here:
mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null
fi
for srvc in "${LOCAL_SERVICES[@]}"
do
c=0; cw=22; spc=''
@@ -88,20 +77,24 @@ fi
fi
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}iDS-Node${nid} (${nip})${idsST[Reset]}${idsCL[LightCyan]} ${LH}${idsCL[Default]}"
DIVIDER false green
for srvc in "${NODE_SERVICES[@]}"
do
c=0; cw=22; spc=''
spc1=${cw}-${#NM_SERVICES[${srvc}]}
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${NM_SERVICES[${srvc}]}$spc: "
if [ $(${NCMD} pgrep ${srvc} | wc -l) -gt "0" ]; then
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
rm -f ${FOLDER}/${nip}-${srvc}.down
else
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
touch ${FOLDER}/${nip}-${srvc}.down
fi
done
if [ $(CHECK_HOST ${1}) = "false" ]; then
for srvc in "${NODE_SERVICES[@]}"
do
c=0; cw=22; spc=''
spc1=${cw}-${#NM_SERVICES[${srvc}]}
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${NM_SERVICES[${srvc}]}$spc: "
if [ $(${NCMD} pgrep ${srvc} | wc -l) -gt "0" ]; then
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
rm -f ${FOLDER}/${nip}-${srvc}.down
else
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
touch ${FOLDER}/${nip}-${srvc}.down
fi
done
else
echo -e "${idsCL[Red]}Node is Down!${idsCL[Default]}"
fi
echo
nid=`expr $nid + 1`
done
@@ -115,34 +108,38 @@ fi
if [[ $(/sbin/ip -o -4 addr list ens192 | awk '{print $4}' | cut -d/ -f1) != *"${nip}"* ]] && [ "${isreplhost}" = "false" ]; then
echo -e " ${idsST[Bold]}${idsCL[LightCyan]}iDS-Node${nid} (${nip})${idsST[Reset]}${idsCL[Default]}"
DIVIDER false green
for rcheck in "${REPL_CHECK[@]}"; do
c=0; cw=22; spc=''
spc1=${cw}-${#REPL_DESC[${rcheck}]}
timeout=`date --date='5 seconds' +%s`
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${REPL_DESC[${rcheck}]}${spc}: "
checked=false
until [ "${checked}" = "" ]; do
if [ "${NCMD}" = "" ]; then
checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl`
if [ $(CHECK_HOST ${1}) = "false" ]; then
for rcheck in "${REPL_CHECK[@]}"; do
c=0; cw=22; spc=''
spc1=${cw}-${#REPL_DESC[${rcheck}]}
timeout=`date --date='5 seconds' +%s`
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
echo -en " ${REPL_DESC[${rcheck}]}${spc}: "
checked=false
until [ "${checked}" = "" ]; do
if [ "${NCMD}" = "" ]; then
checked=`ssh root@${nip} "cat ${REPL_CHECKS[${rcheck}]}/test.repl" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl`
else
checked="`ssh root@10.5.10.51 \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`"
fi
#cdate=`date +%s`
if [ "`date +%s`" -gt "$timeout" ]; then
timeout=true
break
fi
done
if [ "${timeout}" != "true" ]; then
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
rm -f ${FOLDER}/${nip}-${rcheck}.down
else
checked="`ssh root@10.5.10.51 \"ssh root@${nip} \"cat ${REPL_CHECKS[${rcheck}]}/test.repl\" | diff - ${REPL_CHECKS[${rcheck}]}/test.repl\"`"
fi
#cdate=`date +%s`
if [ "`date +%s`" -gt "$timeout" ]; then
timeout=true
break
echo -e "${idsCL[Red]}Timeout${idsCL[Default]}"
touch ${FOLDER}/${nip}-${rcheck}.down
#echo "Timeout occurred in waiting for replication between primary node and iDS-Node${nid} (${nip}) for the replicated folder of '${rcheck}'." | mail -s "Status-Check" ${STATUS_CHECK_EMAIL}
fi
done
if [ "${timeout}" != "true" ]; then
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
rm -f ${FOLDER}/${nip}-${rcheck}.down
else
echo -e "${idsCL[Red]}Timeout${idsCL[Default]}"
touch ${FOLDER}/${nip}-${rcheck}.down
#echo "Timeout occurred in waiting for replication between primary node and iDS-Node${nid} (${nip}) for the replicated folder of '${rcheck}'." | mail -s "Status-Check" ${STATUS_CHECK_EMAIL}
fi
done
else
echo -e "${idsCL[Red]}Node is Down!${idsCL[Default]}"
fi
echo
fi
nid=`expr $nid + 1`