Update temp.inc.sh

This commit is contained in:
2024-04-28 22:17:41 -05:00
parent 6d41314873
commit f6566d7494

View File

@@ -126,43 +126,44 @@ CHECKTEMP(){
c=0; spct=''; [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]] && spc1=`expr 6 - ${#temp_f}` || spc1=`expr 7 - ${#temp_f}`
until [ ${c} = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done
reading="${lclr}${lmd}${spct}${temp_f_disp}${GAUGESH}"
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR_DESC}${idsST[Reset]}${spc}${idsCL[Default]}: ${reading}"
OLD1_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND date >= DATE_SUB(NOW(), INTERVAL 30 MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL 20 MINUTE) ORDER BY date ASC LIMIT 1")); OLD1_temp_f=${OLD1_temp_f[1]}
OLD2_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND date >= DATE_SUB(NOW(), INTERVAL 60 MINUTE) AND date >= DATE_SUB(NOW(), INTERVAL 50 MINUTE) ORDER BY date ASC LIMIT 1")); OLD2_temp_f=${OLD2_temp_f[1]}
if [ "${avgdays}" = "noavg" ] && [[ "${SENSOR}" != *"FAN"* ]] && [ "${OLD1_temp_f}" != "" ]; then
if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD1_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD1_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then
reading="${reading} ${idsCL[White]}\u23F9 "
echo -en " ${idsCL[White]}\u23F9 "
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD1_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
reading="${reading} ${idsCL[LightRed]}\u25B2 "
echo -en " ${idsCL[LightRed]}\u25B2 "
elif [ $(bc -l <<< "${OLD1_temp_f} < ${temp_f}") -eq 1 ]; then
reading="${reading} ${idsCL[Magenta]}\u25B2 "
echo -en " ${idsCL[Magenta]}\u25B2 "
elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD1_temp_f}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then
reading="${reading} ${idsCL[LightGreen]}\u25BC "
echo -en " ${idsCL[LightGreen]}\u25BC "
elif [ $(bc -l <<< "${temp_f} < ${OLD1_temp_f}") -eq 1 ]; then
reading="${reading} ${idsCL[LightCyan]}\u25BC "
echo -en " ${idsCL[LightCyan]}\u25BC "
else
reading="${reading} "
echo -en "${reading} "
fi
if [ "${OLD2_temp_f}" != "" ]; then
if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD2_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD2_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then
reading="${reading}${idsCL[White]}\u23F9 "
echo -en "${idsCL[White]}\u23F9 "
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD2_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
reading="${reading}${idsCL[LightRed]}\u25B2 "
echo -en "${idsCL[LightRed]}\u25B2 "
elif [ $(bc -l <<< "${OLD2_temp_f} < ${temp_f}") -eq 1 ]; then
reading="${reading}${idsCL[Magenta]}\u25B2 "
echo -en "${idsCL[Magenta]}\u25B2 "
elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD2_temp_f}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then
reading="${reading}${idsCL[LightGreen]}\u25BC "
echo -en "${idsCL[LightGreen]}\u25BC "
elif [ $(bc -l <<< "${temp_f} < ${OLD2_temp_f}") -eq 1 ]; then
reading="${reading}${idsCL[LightCyan]}\u25BC "
echo -en "${idsCL[LightCyan]}\u25BC "
else
reading="${reading} "
echo -en " "
fi
else
reading="${reading} "
echo -en " "
fi
elif [ "${avgdays}" = "noavg" ]; then
reading="${reading} "
echo -en " "
fi
else
@@ -179,9 +180,9 @@ CHECKTEMP(){
lmd=""
reading="${idsCL[Yellow]}Sensor Offline "
fi
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR_DESC}${idsST[Reset]}${spc}${idsCL[Default]}: ${reading}${idsCL[Default]}"
echo -en "${idsCL[Default]}"
if [ "${avgdays}" != "noavg" ]; then
echo -en " / ${idsCL[Yellow]}Calculating ${avgdays_disp} average ... "
average=$(AVERAGETEMP ${SENSOR} ${avgdays})