Update temp.inc.sh

This commit is contained in:
2024-05-09 20:54:00 -05:00
parent 35bb42ddf0
commit b6647fbddd

View File

@@ -217,9 +217,20 @@ CHECKTEMP(){
if [ ${DETAILS} -eq 1 ]; then
for M in 15 30 60 120; 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 ${M} MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL $(expr ${M} - 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
lclr="${idsCL[White]}"
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
lclr="${idsCL[LightRed]}"
elif [ $(bc -l <<< "${OLD_temp_f[1]} < ${temp_f}") -eq 1 ]; then
lclr="${idsCL[Magenta]}"
elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f[1]}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then
lclr="${idsCL[LightGreen]}"
elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f[1]}") -eq 1 ]; then
lclr="${idsCL[LightCyan]}"
fi
([ "${temp_h}" != "" ] && [ "${temp_h}" != "0" ]) && echo -en "${idsCL[White]}| " || echo -n " "
[ ${#M} -eq 2 ] && echo -n " "
echo -e "${idsCL[White]} ${idsCL[Default]}${M} Mins Ago ${idsCL[Default]}${temp_f_disp}${GAUGESH}"
echo -e "${idsCL[White]} ${lclr}${M} Mins Ago ${OLD_temp_f}${GAUGESH}"
done