From d52848cdc18518265286ddd204fda5220808d7a5 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 29 Apr 2024 08:47:27 -0500 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 8eb4dec6..bfd31509 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -131,18 +131,22 @@ CHECKTEMP(){ if [ "${avgdays}" = "noavg" ] && [[ "${SENSOR}" != *"FAN"* ]]; then for R in ${PW_TEMPIND_RANGE[@]}; do OLD_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND date >= DATE_SUB(NOW(), INTERVAL ${R} MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL $(expr ${R} - 7) MINUTE) ORDER BY date ASC LIMIT 1")) - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f[1]}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f[1]}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then - echo -en "${idsCL[White]}\u23F9 " - elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then - echo -en "${idsCL[LightRed]}\u25B2 " - elif [ $(bc -l <<< "${OLD_temp_f[1]} < ${temp_f}") -eq 1 ]; then - echo -en "${idsCL[Magenta]}\u25B2 " - elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f[1]}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then - echo -en "${idsCL[LightGreen]}\u25BC " - elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f[1]}") -eq 1 ]; then - echo -en "${idsCL[LightCyan]}\u25BC " + if [ "${OLD_temp_f[1]}" != "" ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f[1]}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f[1]}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + echo -en "${idsCL[White]}\u23F9 " + elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then + echo -en "${idsCL[LightRed]}\u25B2 " + elif [ $(bc -l <<< "${OLD_temp_f[1]} < ${temp_f}") -eq 1 ]; then + echo -en "${idsCL[Magenta]}\u25B2 " + elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f[1]}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then + echo -en "${idsCL[LightGreen]}\u25BC " + elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f[1]}") -eq 1 ]; then + echo -en "${idsCL[LightCyan]}\u25BC " + else + echo -en " " + fi else - echo -en " " + echo -en "${idsCL[LightCyan]}\u2BBE " fi done elif [ "${avgdays}" = "noavg" ]; then