This commit is contained in:
2023-12-12 13:58:18 -06:00
parent c40aad23df
commit de9d727f48
3 changed files with 59 additions and 72 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
VERS='5.1.13-12122023'
VERS='5.1.19-12122023'
NM_BETA=false
noheader=' service status-check nightlyrephp7.3-fpm,new backup report check checkcerts gitea update-nodes copynpmcerts singleservercheck update-dyndns backup-offsitepfsense gui nightlyreview update log betacheck '

View File

@@ -3,37 +3,23 @@ STATUS(){
start=$(date +%s)
log_start=$(date "+%Y-%m-%d %H:%M:%S")
if [ "${1}" != "-h" ]; then
if [ "${1}" != "" ] && [ "${NM_NODETYPES[${1^^}]}" != "" ]; then
ntss=${1^^}
ntypesel=(${ntss})
STATUS_ACTION=${2}
else
ntss=""
ntypesel=(${NM_NODE_TYPES[@]})
[ "${1}" == "sync" ] && STATUS_ACTION=repl || STATUS_ACTION=${1}
fi
if [ "${1}" != "" ] && [ "${NM_NODETYPES[${1^^}]}" != "" ]; then
ntss=${1^^}
ntypesel=(${ntss})
STATUS_ACTION=${2}
else
ntss=""
ntypesel=(${NM_NODE_TYPES[@]})
[ "${1}" == "sync" ] && STATUS_ACTION=repl || STATUS_ACTION=${1}
fi
while [ $# -gt 0 ]; do
case "$1" in
-site) DEL_SITE=${2};;
-ssl) DEL_SSL=${2};;
-h)
echo -e "Usage: ${idsCL[Yellow]}[nodemgmt or nmg] status {status-check}${idsCL[Default]} {"
width=25
printf "%-${width}s- %s\n" " {status-check}" "By default will check everything, otherwise specifically specify item to check:"
printf "%-${width}s- %s\n" " services" "Will verify status of all node services"
printf "%-${width}s- %s\n" " dockers" "Will verify status of all node dockers"
printf "%-${width}s- %s\n" " repl" "Will verify status of all node replications"
echo -e "}\n"
rm -Rf ${STATUSRUN_TMPFOLDER}
exit 0
;;
esac
shift
done
# while [ $# -gt 0 ]; do
# case "$1" in
# -site) DEL_SITE=${2};;
# -ssl) DEL_SSL=${2};;
#
# esac
# shift
# done
PRI_CW=40
declare -i cw; declare -i spc1; declare -i c

View File

@@ -1023,52 +1023,53 @@ GUI(){
if [ "${2}" == "freespace" ]; then
STATUS freespace ${3}
else
STATUSRUNS=($(find ${NM_TMPFOLDER}/* -maxdepth 1 -type d -iname "status-*" 2>/dev/null))
if [ ${#STATUSRUNS[@]} -lt 3 ]; then
STATUS_START=$(date +%Y-%m-%d-%H-%M-%S)
STATUSRUN_TMPFOLDER="${NM_TMPFOLDER}/status-${STATUS_START}"
mkdir ${STATUSRUN_TMPFOLDER}
touch "${STATUSRUN_TMPFOLDER}/status-check.running"
rm -f ${NM_TMPFOLDER}/.overload
if [ "${2}" == "report" ]; then
echo "${STATUS_START} - LOCAL - ${NODE_HOSTNAME} - Starting Status Check" >> ${NM_LOGFILE}
echo -e "${STATUS_START} - Starting status check #############################\n" > ${STATUSRUN_TMPFOLDER}/status-check.running
STATUS report ${3} ${4} >> ${STATUSRUN_TMPFOLDER}/status-check.running
echo -e "\n\n$(date +%Y-%m-%d-%H-%M-%S) - Finished status check #############################\n" >> ${STATUSRUN_TMPFOLDER}/status-check.running
echo "$(date +%Y-%m-%d-%H-%M-%S) - LOCAL - ${NODE_HOSTNAME} - Completed Status Check" >> ${NM_LOGFILE}
rm -f ${NM_LOGFOLDER}/status-check.lastrun
mv ${STATUSRUN_TMPFOLDER}/status-check.running ${NM_LOGFOLDER}/status-check.lastrun
rm -Rf ${STATUSRUN_TMPFOLDER}
if [ ! -f ${NM_TMPFOLDER}/.statusclean ] || [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/.statusclean)) -ge 3600 ]; then
for oldstatus_check in ${NM_TMPFOLDER}/status-*; do
[ -d "${oldstatus_check}" ] && [ $(expr $(date +%s) - $(stat -c %Y ${oldstatus_check})) -ge 1200 ] && rm -Rf ${oldstatus_check}
done
touch ${NM_TMPFOLDER}/.statusclean
fi
if [ "${3}" == "email" ]; then
echo -e "\n\n" >> ${NM_LOGFOLDER}/status-check.lastrun
DOWNLIST report >> ${NM_LOGFOLDER}/status-check.lastrun
STATUSLOG="$(cat ${NM_LOGFOLDER}/status-check.lastrun)"
SENDNOTICE "Status Report" "Status Report\n${STATUSLOG}"
fi
else
STATUS ${2} ${3} ${4}
rm -Rf ${STATUSRUN_TMPFOLDER}
fi
else
if [ ! -f ${NM_TMPFOLDER}/.statusclean ] || [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/.statusclean)) -ge 3600 ]; then
for oldstatus_check in ${NM_TMPFOLDER}/status-*; do
[ -d "${oldstatus_check}" ] && [ $(expr $(date +%s) - $(stat -c %Y ${oldstatus_check})) -ge 1200 ] && rm -Rf ${oldstatus_check}
done
touch ${NM_TMPFOLDER}/.statusclean
STATUSRUNS=($(find ${NM_TMPFOLDER}/* -maxdepth 1 -type d -iname "status-*" 2>/dev/null))
fi
STATUSRUNS=($(find ${NM_TMPFOLDER}/* -maxdepth 1 -type d -iname "status-*" 2>/dev/null))
if [ "${2}" == "-h" ] || [ "${2}" == "-help" ]; then
echo -e "Usage: ${idsCL[Yellow]}[nodemgmt or nmg] status {status-check}${idsCL[Default]} {"
width=25
printf "%-${width}s- %s\n" " {status-check}" "By default will check everything, otherwise specifically specify item to check:"
printf "%-${width}s- %s\n" " services" "Will verify status of all node services"
printf "%-${width}s- %s\n" " dockers" "Will verify status of all node dockers"
printf "%-${width}s- %s\n" " repl" "Will verify status of all node replications"
echo -e "}\n"
rm -Rf ${STATUSRUN_TMPFOLDER}
exit 0
else
if [ ${#STATUSRUNS[@]} -lt 3 ]; then
${NM_SCRIPT} status ${2} ${3} ${4}
exit 0
STATUS_START=$(date +%Y-%m-%d-%H-%M-%S)
STATUSRUN_TMPFOLDER="${NM_TMPFOLDER}/status-${STATUS_START}"
mkdir ${STATUSRUN_TMPFOLDER}
touch "${STATUSRUN_TMPFOLDER}/status-check.running"
rm -f ${NM_TMPFOLDER}/.overload
if [ "${2}" == "report" ]; then
echo "${STATUS_START} - LOCAL - ${NODE_HOSTNAME} - Starting Status Check" >> ${NM_LOGFILE}
echo -e "${STATUS_START} - Starting status check #############################\n" > ${STATUSRUN_TMPFOLDER}/status-check.running
STATUS report ${3} ${4} >> ${STATUSRUN_TMPFOLDER}/status-check.running
echo -e "\n\n$(date +%Y-%m-%d-%H-%M-%S) - Finished status check #############################\n" >> ${STATUSRUN_TMPFOLDER}/status-check.running
echo "$(date +%Y-%m-%d-%H-%M-%S) - LOCAL - ${NODE_HOSTNAME} - Completed Status Check" >> ${NM_LOGFILE}
rm -f ${NM_LOGFOLDER}/status-check.lastrun
mv ${STATUSRUN_TMPFOLDER}/status-check.running ${NM_LOGFOLDER}/status-check.lastrun
rm -Rf ${STATUSRUN_TMPFOLDER}
if [ "${3}" == "email" ]; then
echo -e "\n\n" >> ${NM_LOGFOLDER}/status-check.lastrun
DOWNLIST report >> ${NM_LOGFOLDER}/status-check.lastrun
STATUSLOG="$(cat ${NM_LOGFOLDER}/status-check.lastrun)"
SENDNOTICE "Status Report" "Status Report\n${STATUSLOG}"
fi
else
STATUS ${2} ${3} ${4}
rm -Rf ${STATUSRUN_TMPFOLDER}
fi
else
[ "${MM_ACTION}" != "report" ] && echo -e "${idsCL[LightRed]}Whooooaaaaa there cowboy, we got 3 threads running already.... easy killer!${idsCL[Default]}\n"
if [ ! -f ${NM_TMPFOLDER}/.overload ] || [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/.overload)) -ge 600 ]; then