Update nodemgmt-scripts.sh
This commit is contained in:
@@ -29,7 +29,7 @@ STATUS(){
|
||||
########################
|
||||
if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
|
||||
if [ "${ST_ACTION}" != "check" ]; then
|
||||
echo -en "${idsCL[LightCyan]}Setting up replication checks for next status check ... ${idsCL[Default]}"
|
||||
echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}"
|
||||
fi
|
||||
for NTYPE in "${NODE_TYPES[@]}"; do
|
||||
PH=${NTYPE}_HOSTS[0]
|
||||
@@ -175,89 +175,91 @@ STATUS(){
|
||||
|
||||
if [ "${ST_ACTION}" != "dockers" ]; then
|
||||
var2=${NTYPE}_SERVICES_CHECK[@]
|
||||
for srvc in "${!var2}"; do
|
||||
NOGOCHK=true;
|
||||
# if [ ${srvc} = "gitea" ] || [ ${srvc} = "pdnsadmin" ] || [ ${srvc} = "pdnsadmin.socket" ]; then
|
||||
if [ ${srvc} = "gitea" ]; then
|
||||
if [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *10.10.1.120* ]] && [[ "${NTYPE}" != "LPD" ]]; then
|
||||
NOGOCHK=false;
|
||||
fi
|
||||
fi
|
||||
if [ ${NOGOCHK} = true ]; then
|
||||
if [ "${ST_ACTION}" != "check" ]; then
|
||||
if [ "${ST_ACTION}" != "report" ]; then
|
||||
c=0; cw=30; spc=''
|
||||
spc1=${cw}-${#NM_SERVICES[${srvc}]}
|
||||
until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
else
|
||||
spc=' '
|
||||
fi
|
||||
echo -en " ${NM_SERVICES[${srvc}]}$spc: "
|
||||
fi
|
||||
srvctst=$(${NCMD} systemctl is-active ${srvc})
|
||||
#echo "${NCMD} systemctl is-active ${srvc} = ${srvctst}"
|
||||
#if [ "${srvctst}" = "active" ]; then echo "yes"; else echo "no"; fi
|
||||
if [ "${srvctst}" != "active" ] && [ "${srvc}" = "mysql" ]; then
|
||||
mysqlgo=false;
|
||||
[ "$(${NCMD} systemctl is-active mariadb)" = "active" ] && mysqlgo=true;
|
||||
elif [ "${srvctst}" != "active" ] && [ "${srvc}" = "mariadb" ]; then
|
||||
mysqlgo=false;
|
||||
[ "$(${NCMD} systemctl is-active mysql)" = "active" ] && mysqlgo=true;
|
||||
elif [ "${srvctst}" = "active" ] && ([ "${srvc}" = "mysql" ] || [ "${srvc}" = "mariadb" ]); then
|
||||
mysqlgo=true
|
||||
fi
|
||||
# echo "mysqlgo=${mysqlgo}"
|
||||
if [ "${srvctst}" != "active" ] && [ "${mysqlgo}" != "true" ]; then
|
||||
if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then
|
||||
if [ "${ST_ACTION}" != "check" ]; then
|
||||
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
|
||||
fi
|
||||
SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" "${NM_SERVICES[${srvc}]} is down" 1
|
||||
touch ${FOLDER}/${nip}-${srvc}.down
|
||||
echo "$(date) - ${nip} - ${NM_NODETYPES[$NTYPE]}-Node${nid} - ${NM_SERVICES[${srvc}]} is down" >> ${LOGFILE}
|
||||
|
||||
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)
|
||||
touch ${FOLDER}/${nip}-${srvc}.down
|
||||
if [ "${srvc}" = "mysql" ]; then
|
||||
${NCMD} systemctl restart ${srvc}
|
||||
fi
|
||||
fi
|
||||
if [ "${ST_ACTION}" != "check" ]; then
|
||||
echo -e "${idsCL[Red]}Not running for $(SHOW_TIME ${toterrtime})${idsCL[Default]}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ "${ST_ACTION}" != "check" ]; then
|
||||
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
|
||||
fi
|
||||
if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then
|
||||
if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then
|
||||
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime)
|
||||
else
|
||||
toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
|
||||
fi
|
||||
SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" "${NM_SERVICES[${srvc}]} is back UP! It was down for $(SHOW_TIME ${toterrtime})"
|
||||
echo "$(date) - ${nip} - ${NM_NODETYPES[$NTYPE]}-Node${nid} - ${NM_SERVICES[${srvc}]} is back up, it was down for $(SHOW_TIME ${toterrtime})" >> ${LOGFILE}
|
||||
|
||||
rm -f ${FOLDER}/${nip}-${srvc}.down
|
||||
rm -f ${FOLDER}/${nip}-${srvc}.errtime
|
||||
|
||||
fi
|
||||
# if [ "${srvc}" == "pdnsadmin.socket" ] || [ "${srvc}" == "pdnsadmin" ] || [ "${srvc}" == "gitea" ]; then
|
||||
if [ "${srvc}" == "gitea" ]; then
|
||||
rm -f ${FOLDER}/*-${srvc}.down
|
||||
rm -f ${FOLDER}/*-${srvc}.errtime
|
||||
fi
|
||||
fi
|
||||
[ "${mysqlgo}" = "true" ] && unset mysqlgo
|
||||
fi
|
||||
done
|
||||
srvcstotest="$(join_by , ${!var2})"
|
||||
echo "$nip - $srvcstotest"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# for srvc in "${!var2}"; do
|
||||
# NOGOCHK=true;
|
||||
# [ "${srvc}" == "gitea" ] && [ "${NTYPE}" == "WEB" ] && [[ $($NCMD /sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) != *${WEB_HOSTS[0]}* ]] && NOGOCHK=false;
|
||||
# if [ ${NOGOCHK} = true ]; then
|
||||
# if [ "${ST_ACTION}" != "check" ]; then
|
||||
# if [ "${ST_ACTION}" != "report" ]; then
|
||||
# c=0; cw=30; spc=''
|
||||
# spc1=${cw}-${#NM_SERVICES[${srvc}]}
|
||||
# until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
# else
|
||||
# spc=' '
|
||||
# fi
|
||||
# echo -en " ${NM_SERVICES[${srvc}]}$spc: "
|
||||
# fi
|
||||
# srvctst=$(${NCMD} systemctl is-active ${srvc})
|
||||
# if [ "${srvctst}" != "active" ] && [ "${srvc}" = "mysql" ]; then
|
||||
# mysqlgo=false;
|
||||
# [ "$(${NCMD} systemctl is-active mariadb)" = "active" ] && mysqlgo=true;
|
||||
# elif [ "${srvctst}" != "active" ] && [ "${srvc}" = "mariadb" ]; then
|
||||
# mysqlgo=false;
|
||||
# [ "$(${NCMD} systemctl is-active mysql)" = "active" ] && mysqlgo=true;
|
||||
# elif [ "${srvctst}" = "active" ] && ([ "${srvc}" = "mysql" ] || [ "${srvc}" = "mariadb" ]); then
|
||||
# mysqlgo=true
|
||||
# fi
|
||||
# # echo "mysqlgo=${mysqlgo}"
|
||||
# if [ "${srvctst}" != "active" ] && [ "${mysqlgo}" != "true" ]; then
|
||||
# if [ ! -f ${FOLDER}/${nip}-${srvc}.down ]; then
|
||||
# if [ "${ST_ACTION}" != "check" ]; then
|
||||
# echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
|
||||
# fi
|
||||
# SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" "${NM_SERVICES[${srvc}]} is down" 1
|
||||
# touch ${FOLDER}/${nip}-${srvc}.down
|
||||
# echo "$(date) - ${nip} - ${NM_NODETYPES[$NTYPE]}-Node${nid} - ${NM_SERVICES[${srvc}]} is down" >> ${LOGFILE}
|
||||
#
|
||||
# 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)
|
||||
# touch ${FOLDER}/${nip}-${srvc}.down
|
||||
# if [ "${srvc}" = "mysql" ]; then
|
||||
# ${NCMD} systemctl restart ${srvc}
|
||||
# fi
|
||||
# fi
|
||||
# if [ "${ST_ACTION}" != "check" ]; then
|
||||
# echo -e "${idsCL[Red]}Not running for $(SHOW_TIME ${toterrtime})${idsCL[Default]}"
|
||||
# fi
|
||||
# fi
|
||||
# else
|
||||
# if [ "${ST_ACTION}" != "check" ]; then
|
||||
# echo -e "${idsCL[Green]}Running${idsCL[Default]}"
|
||||
# fi
|
||||
# if [ -f ${FOLDER}/${nip}-${srvc}.down ]; then
|
||||
# if [ -f ${FOLDER}/${nip}-${srvc}.errtime ]; then
|
||||
# toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.errtime)
|
||||
# else
|
||||
# toterrtime=`date +%s`-$(stat -c %Y ${FOLDER}/${nip}-${srvc}.down)
|
||||
# fi
|
||||
# SENDNOTICE "${NM_NODETYPES[$NTYPE]}-Node${nid}-${nip}" "${NM_SERVICES[${srvc}]} is back UP! It was down for $(SHOW_TIME ${toterrtime})"
|
||||
# echo "$(date) - ${nip} - ${NM_NODETYPES[$NTYPE]}-Node${nid} - ${NM_SERVICES[${srvc}]} is back up, it was down for $(SHOW_TIME ${toterrtime})" >> ${LOGFILE}
|
||||
#
|
||||
# rm -f ${FOLDER}/${nip}-${srvc}.down
|
||||
# rm -f ${FOLDER}/${nip}-${srvc}.errtime
|
||||
#
|
||||
# fi
|
||||
# # if [ "${srvc}" == "pdnsadmin.socket" ] || [ "${srvc}" == "pdnsadmin" ] || [ "${srvc}" == "gitea" ]; then
|
||||
# if [ "${srvc}" == "gitea" ]; then
|
||||
# rm -f ${FOLDER}/*-${srvc}.down
|
||||
# rm -f ${FOLDER}/*-${srvc}.errtime
|
||||
# fi
|
||||
# fi
|
||||
# [ "${mysqlgo}" = "true" ] && unset mysqlgo
|
||||
# fi
|
||||
# done
|
||||
fi
|
||||
|
||||
if [[ -v ${NTYPE}_DOCKER ]] && [ "${ST_ACTION}" != "services" ]; then
|
||||
|
||||
Reference in New Issue
Block a user