diff --git a/defaults.inc b/defaults.inc index ec8eb9d3..69727f83 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERS='5.1.58-01062024' +VERS='5.1.59-01062024' 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 ' @@ -28,6 +28,7 @@ if [ -f ${NM_FOLDER}/conf/defaults.local.inc ]; then declare -A NM_CERTPATHS declare -A NM_WWWPATHS declare -A NM_DYNDNS_SITES + declare -A NM_HOST_CPULEVELS source ${NM_FOLDER}/conf/defaults.local.inc diff --git a/inc/status.inc b/inc/status.inc index 02bec94e..ccb2ed2b 100755 --- a/inc/status.inc +++ b/inc/status.inc @@ -444,17 +444,24 @@ STATUS_NODE(){ 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 [ "${cpu_usage}" != "" ]; then - if [ $(ROUND_NUMBER ${cpu_usage}) -lt 40 ]; then + if [ "${NM_HOST_CPULEVELS[${nip}]}" != "" ]; then + echo ${NM_HOST_CPULEVELS[${nip}]} | cut -d',' -f 1 | read cpu_warn + echo ${NM_HOST_CPULEVELS[${nip}]} | cut -d',' -f 2 | read cpu_crit + else + cpu_warn=40 + cpu_crit=80 + fi + if [ $(ROUND_NUMBER ${cpu_usage}) -lt ${cpu_warn} ]; then CUFC="${idsCL[Green]}" 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 18 ]; then - SENDNOTICE "${NM_HOSTNAMES[${nip}]}[${nip}] NORMAL CPU USAGE" "${NM_HOSTNAMES[${nip}]}[${nip}] has returned to normal cpu usage: ${cpu_usage}%" + [ -f ${NM_TMPFOLDER}/${nip}.cpu_usage.sent ] && 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}) -lt 80 ]; then + elif [ $(ROUND_NUMBER ${cpu_usage}) -lt ${cpu_crit} ]; then CUFC="${idsCL[LightYellow]}" [ -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm ] && rm -f ${NM_TMPFOLDER}/${nip}.cpu_usage.norm if [ ! -f ${NM_TMPFOLDER}/${nip}.cpu_usage.warn ]; then @@ -462,6 +469,7 @@ STATUS_NODE(){ 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 + touch ${NM_TMPFOLDER}/${nip}.cpu_usage.sent fi else CUFC="${idsCL[LightRed]}" @@ -471,6 +479,7 @@ STATUS_NODE(){ 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 + touch ${NM_TMPFOLDER}/${nip}.cpu_usage.sent fi fi fi