From a62f20f42ac172b770abe4437f2c89fda8de4a49 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 26 Dec 2023 13:37:52 -0600 Subject: [PATCH] update --- defaults.inc | 2 +- inc/temp.inc.sh | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/defaults.inc b/defaults.inc index 7d6fbd81..5e012e47 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,5 +1,5 @@ -VERS='2.5.57-12242023' +VERS='2.5.60-12262023' noheader=' update service dailytemp confsync ' diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 5087dc6c..af4487ba 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -92,8 +92,10 @@ CHECKTEMP(){ } CHECKTEMPSENSOR(){ - echo ${PW_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn - echo ${PW_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit + if [ "${PW_THRESHOLDS[${1}]}" != "" ]; then + echo ${PW_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn + echo ${PW_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit + fi [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ] && GAUGESH="'%" || GAUGESH="'F" if [ "${6}" != "noavg" ]; then @@ -117,8 +119,12 @@ CHECKTEMPSENSOR(){ temp_probe_c=`IDS_NUMBER_FORMAT $(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') 2 yes` elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then - temp_c=$(vcgencmd measure_temp) - temp_c=${temp_c%\'*}; temp_c=${temp_c#*=} + if [[ "${1}" = %"CPU"% ]]; then + temp_c=$(vcgencmd measure_temp) + temp_c=${temp_c%\'*}; temp_c=${temp_c#*=} + elif [[ "${1}" = %"FAN"% ]]; then + temp_c=$(cat /sys/class/hwmon/hwmon2/fan1_input) + fi elif [ "${PW_SENSOR_TYPE[${1}]}" == "remotesystem" ]; then temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} vcgencmd measure_temp) @@ -143,7 +149,13 @@ CHECKTEMPSENSOR(){ if [ "${1}" == "ServerRoomTH" ]; then temp_f=`echo "scale=2; ${temp_c}*1.8+32+${PW_ServerRoomTH_Dev}" | bc` else - [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ] && temp_f=$(echo "scale=2; $temp_c/1" | bc -l) || temp_f=$(bc <<< "scale=2; ${temp_c}*1.8+32") + if [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then + temp_f=$(echo "scale=2; $temp_c/1" | bc -l) + elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ] && [[ "${1}" = %"FAN"% ]]; then + temp_f=${temp_c} + else + temp_f=$(bc <<< "scale=2; ${temp_c}*1.8+32") + fi (( $(bc <<<"${temp_f} < 1") )) && [[ "${temp_f}" = *"."* ]] && temp_f="0${temp_f}" fi # echo "HERE: '${temp_c}' -> '${temp_f}'"