This commit is contained in:
2024-01-06 21:09:44 -06:00
parent 580b014015
commit de82f825e9
2 changed files with 37 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERS='5.1.55-01062024'
NM_BETA=false
VERS='5.1.56a-01062024'
NM_BETA=true
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 '
CERT_DAEMON='/snap/bin/certbot'
@@ -209,9 +209,13 @@ DISP_HEADER(){
}
SENDNOTICE(){
[ "${PUSHOVER_USER_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}
if [ "${PUSHOVER_USER_TOKEN}" != "" ]; then
SN_TIT="$(echo -e "${1}" | sed "s/\%/\%25 /g")"
SN_MSG="$(echo -e "${2}" | sed "s/\%/\%25 /g")"
PUSH_TO_MOBILE "${SN_MSG}
$(date)" "${1}" ${3} &
$(date)" "${SN_TIT}" ${3} &
fi
[ "${EMAIL_NOTICE}" != "" ] && echo -e "${2}\n\n$(date)" | mail -s "${1}" ${EMAIL_NOTICE}
}

View File

@@ -442,7 +442,6 @@ STATUS_NODE(){
fi
if [ "${checkhost}" != "false" ] && [ "${checkhostssl}" == "ok" ]; then
[ "${NODETYPE}" != "OFW" ] && cpu_usage=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${nip} "/opt/idssys/defaults/get-data.sh cpu-usage") || cpu_usage=""
if [ "${STATUS_ACTION}" != "check" ]; then
if ([ "${STATUS_ACTION}" == "report" ] && [ "${2}" == "email" ]) || [ "${STATUS_ACTION}" != "report" ]; then
@@ -475,6 +474,35 @@ STATUS_NODE(){
rm -f ${NM_TMPFOLDER}/${nip}.*
fi
if [ "${cpu_usage}" != "" ]; then
if [ $(ROUND_NUMBER ${cpu_usage}) < 40 ]; then
if [ -f ${NM_TMPFOLDER}/${nip}.cpu_usage.warn ] || [ -f ${NM_TMPFOLDER}/${nip}.cpu_usage.warn ]; then
if [ ! -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm ]; then
touch ${NM_TMPFOLDER}/${nip}.cpu_usage.norm
elif [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${nip}.cpu_usage.norm)) -ge 180 ]; then
SENDNOTICE "${NM_HOSTNAMES[${nip}]}[${nip}] NORMAL CPU USAGE" "${NM_HOSTNAMES[${nip}]}[${nip}] has returned to normal cpu usage: ${cpu_usage}%"
rm -f ${NM_TMPFOLDER}/${nip}.cpu_usage.*
fi
fi
elif [ $(ROUND_NUMBER ${cpu_usage}) < 80 ]; then
[ -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm ] && rm -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm
if [ ! -f ${NM_TMPFOLDER}/${nip}.cpu_usage.warn ]; then
touch ${NM_TMPFOLDER}/${nip}.cpu_usage.warn
elif [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${nip}.cpu_usage.warn)) -ge 180 ]; then
SENDNOTICE "${NM_HOSTNAMES[${nip}]}[${nip}] WARNING HIGH CPU USAGE" "${NM_HOSTNAMES[${nip}]}[${nip}] has high cpu usage: ${cpu_usage}%"
touch ${NM_TMPFOLDER}/${nip}.cpu_usage.warn
fi
else
[ -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm ] && rm -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm
if [ ! -f ${NM_TMPFOLDER}/${nip}.cpu_usage.crit ]; then
touch ${NM_TMPFOLDER}/${nip}.cpu_usage.crit
elif [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${nip}.cpu_usage.crit)) -ge 60 ]; then
SENDNOTICE "${NM_HOSTNAMES[${nip}]}[${nip}] CRITICAL HIGH CPU USAGE" "${NM_HOSTNAMES[${nip}]}[${nip}] has CRITICALLY high cpu usage: ${cpu_usage}%" 1
touch ${NM_TMPFOLDER}/${nip}.cpu_usage.crit
fi
fi
fi
########################
## SERVICES CHECK
########################