Update temp.inc.sh

This commit is contained in:
2024-04-29 10:25:35 -05:00
parent 99a13429cd
commit 69d5bbc464

View File

@@ -155,46 +155,6 @@ CHECKTEMP(){
echo -en " " echo -en " "
fi fi
# 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
# echo -en " ${idsCL[White]}\u23F9 "
# elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD1_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
# echo -en " ${idsCL[LightRed]}\u25B2 "
# elif [ $(bc -l <<< "${OLD1_temp_f} < ${temp_f}") -eq 1 ]; then
# echo -en " ${idsCL[Magenta]}\u25B2 "
# elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD1_temp_f}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then
# echo -en " ${idsCL[LightGreen]}\u25BC "
# elif [ $(bc -l <<< "${temp_f} < ${OLD1_temp_f}") -eq 1 ]; then
# echo -en " ${idsCL[LightCyan]}\u25BC "
# else
# echo -en " "
# 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
# echo -en "${idsCL[White]}\u23F9 "
# elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD2_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
# echo -en "${idsCL[LightRed]}\u25B2 "
# elif [ $(bc -l <<< "${OLD2_temp_f} < ${temp_f}") -eq 1 ]; then
# echo -en "${idsCL[Magenta]}\u25B2 "
# elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD2_temp_f}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then
# echo -en "${idsCL[LightGreen]}\u25BC "
# elif [ $(bc -l <<< "${temp_f} < ${OLD2_temp_f}") -eq 1 ]; then
# echo -en "${idsCL[LightCyan]}\u25BC "
# else
# echo -en " "
# fi
# else
# echo -en " "
# fi
# elif [ "${avgdays}" = "noavg" ]; then
# echo -en " "
# fi
else else
temp_f_disp=" " temp_f_disp=" "
lclr="${idsCL[Yellow]}" lclr="${idsCL[Yellow]}"
@@ -338,9 +298,37 @@ CHECKTEMP(){
c=0; spc=''; spc1=`expr ${cw} - ${#sensorname} - 1`; until [ ${c} = ${spc1} ]; do spc="${spc} "; ((c++)); done c=0; spc=''; spc1=`expr ${cw} - ${#sensorname} - 1`; until [ ${c} = ${spc1} ]; do spc="${spc} "; ((c++)); done
IFS=: read -r temp_f temp_h <<< $(CHECKTEMPSENSOR ${SENSOR}); unset IFS IFS=: read -r temp_f temp_h <<< $(CHECKTEMPSENSOR ${SENSOR}); unset IFS
entityid=($(${mysql_conn} -e "SELECT id FROM servermonitor.entities WHERE BINARY name='${sensorname// /_}' AND sensorid='${PW_SENSOR_ID[${SENSOR}]}'")) if [ "${avgdays}" = "noavg" ] && [[ "${SENSOR}" != *"FAN"* ]]; then
OLD1_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND entity=${entityid[1]} 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]} lookback=''
OLD2_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND entity=${entityid[1]} 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]} for R in ${PW_TEMPIND_RANGE[@]}; do
entityid=($(${mysql_conn} -e "SELECT id FROM servermonitor.entities WHERE BINARY name='${sensorname// /_}' AND sensorid='${PW_SENSOR_ID[${SENSOR}]}'"))
OLD_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND entity=${entityid[1]} 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 [ "${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
lookback="${lookback}${idsCL[White]}\u23F9 "
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
lookback="${lookback}${idsCL[LightRed]}\u25B2 "
elif [ $(bc -l <<< "${OLD_temp_f[1]} < ${temp_f}") -eq 1 ]; then
lookback="${lookback}${idsCL[Magenta]}\u25B2 "
elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f[1]}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then
lookback="${lookback}${idsCL[LightGreen]}\u25BC "
elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f[1]}") -eq 1 ]; then
lookback="${lookback}${idsCL[LightCyan]}\u25BC "
else
lookback="${lookback} "
fi
else
lookback="${lookback}${idsCL[Default]}\u22C5 "
fi
done
elif [ "${avgdays}" = "noavg" ]; then
c=0; spca=''; until [ ${c} = ${#PW_TEMPIND_RANGE[@]} ]; do spca="${spca} "; ((c++)); done
lookback="${lookback} "
fi
# entityid=($(${mysql_conn} -e "SELECT id FROM servermonitor.entities WHERE BINARY name='${sensorname// /_}' AND sensorid='${PW_SENSOR_ID[${SENSOR}]}'"))
# OLD1_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND entity=${entityid[1]} 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 entity=${entityid[1]} 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 [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ] || ([ "${TTYPE}" == "fans" ] && [ $(bc -l <<< "${temp_f} > $(bc <<< "scale=2; ${GL_HIGH}+5")") -eq 1 ]); then if [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ] || ([ "${TTYPE}" == "fans" ] && [ $(bc -l <<< "${temp_f} > $(bc <<< "scale=2; ${GL_HIGH}+5")") -eq 1 ]); then
lclr="${idsCL[LightRed]}" lclr="${idsCL[LightRed]}"
@@ -359,37 +347,39 @@ CHECKTEMP(){
reading="${lclr}${lmd}${spct}${temp_f}${GAUGESH}" reading="${lclr}${lmd}${spct}${temp_f}${GAUGESH}"
echo -en "${idsCL[LightCyan]} ${sensorname}${spc}${idsCL[Default]}: ${reading}" echo -en "${idsCL[LightCyan]} ${sensorname}${spc}${idsCL[Default]}: ${reading}"
if [ "${temp_f}" != "" ] && [ "${average}" = "" ] && [ "${OLD1_temp_f}" != "" ]; then if [ "${temp_f}" != "" ] && [ "${average}" = "" ] && [ "${lookback}" != "" ]; then
if [ $(bc -l <<< "${temp_f} <= $(echo "scale=2; ${OLD1_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "${temp_f} >= $(echo "scale=2; ${OLD1_temp_f}-${PW_TEMPIND_DIFF}" | bc)") -eq 1 ]; then echo -en " ${lookback}"
echo -en " ${idsCL[White]}\u23F9 "
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD1_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then # if [ $(bc -l <<< "${temp_f} <= $(echo "scale=2; ${OLD1_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "${temp_f} >= $(echo "scale=2; ${OLD1_temp_f}-${PW_TEMPIND_DIFF}" | bc)") -eq 1 ]; then
echo -en " ${idsCL[LightRed]}\u25B2 " # echo -en " ${idsCL[White]}\u23F9 "
elif [ $(bc -l <<< "${OLD1_temp_f} < ${temp_f}") -eq 1 ]; then # elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD1_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
echo -en " ${idsCL[Magenta]}\u25B2 " # echo -en " ${idsCL[LightRed]}\u25B2 "
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD1_temp_f}-(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then # elif [ $(bc -l <<< "${OLD1_temp_f} < ${temp_f}") -eq 1 ]; then
echo -en " ${idsCL[LightGreen]}\u25BC " # echo -en " ${idsCL[Magenta]}\u25B2 "
elif [ $(bc -l <<< "${temp_f} < ${OLD1_temp_f}") -eq 1 ]; then # elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD1_temp_f}-(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
echo -en " ${idsCL[LightCyan]}\u25BC " # echo -en " ${idsCL[LightGreen]}\u25BC "
else # elif [ $(bc -l <<< "${temp_f} < ${OLD1_temp_f}") -eq 1 ]; then
echo -en " " # echo -en " ${idsCL[LightCyan]}\u25BC "
fi # else
if [ "${OLD2_temp_f}" != "" ]; then # echo -en " "
if [ $(bc -l <<< "${temp_f} <= $(echo "scale=2; ${OLD2_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "${temp_f} >= $(echo "scale=2; ${OLD2_temp_f}-${PW_TEMPIND_DIFF}" | bc)") -eq 1 ]; then # fi
echo -en "${idsCL[White]}\u23F9 " # if [ "${OLD2_temp_f}" != "" ]; then
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD2_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then # if [ $(bc -l <<< "${temp_f} <= $(echo "scale=2; ${OLD2_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "${temp_f} >= $(echo "scale=2; ${OLD2_temp_f}-${PW_TEMPIND_DIFF}" | bc)") -eq 1 ]; then
echo -en "${idsCL[LightRed]}\u25B2 " # echo -en "${idsCL[White]}\u23F9 "
elif [ $(bc -l <<< "${OLD2_temp_f} < ${temp_f}") -eq 1 ]; then # elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD2_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
echo -en "${idsCL[Magenta]}\u25B2 " # echo -en "${idsCL[LightRed]}\u25B2 "
elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD2_temp_f}-(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then # elif [ $(bc -l <<< "${OLD2_temp_f} < ${temp_f}") -eq 1 ]; then
echo -en "${idsCL[LightGreen]}\u25BC " # echo -en "${idsCL[Magenta]}\u25B2 "
elif [ $(bc -l <<< "${temp_f} < ${OLD2_temp_f}") -eq 1 ]; then # elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD2_temp_f}-(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then
echo -en "${idsCL[LightCyan]}\u25BC " # echo -en "${idsCL[LightGreen]}\u25BC "
else # elif [ $(bc -l <<< "${temp_f} < ${OLD2_temp_f}") -eq 1 ]; then
echo -en " " # echo -en "${idsCL[LightCyan]}\u25BC "
fi # else
else # echo -en " "
echo -en " " # fi
fi # else
# echo -en " "
# fi
elif [ "${avgdays}" = "noavg" ]; then elif [ "${avgdays}" = "noavg" ]; then
echo -en " " echo -en " "
fi fi
@@ -412,7 +402,7 @@ CHECKTEMP(){
fi fi
if [ "${average}" != "" ] || [ "${temp_f}" != "" ]; then if [ "${average}" != "" ] || [ "${temp_f}" != "" ]; then
[ "${average}" != "" ] && fws=11 || fws=16 [ "${average}" != "" ] && fws=11 || fws=$(expr 20 - $(expr ${#PW_TEMPIND_RANGE[@]} \* 2))
[ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' ' [ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' ' [ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
if [ "${TTYPE}" == "fans" ]; then if [ "${TTYPE}" == "fans" ]; then