Update temp.inc.sh

This commit is contained in:
2024-02-24 10:25:27 -06:00
parent 528bd9e3c1
commit 6f3c4d75ac

View File

@@ -106,24 +106,31 @@ CHECKTEMP(){
[ "${last_sensor%%-*}" == "${SENSOR%%-*}" ] && [ "${last_sensor}" != "Offsite-ServerRoom" ] && echo -en "\033[1A"
c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done
if [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then
# if [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${idsCL[Yellow]}Pulling data ... "
temp_f=$(CHECKTEMPSENSOR ${SENSOR})
c=0; spct=''; [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]] && spc1=`expr 5 - ${#temp_f}` || spc1=`expr 6 - ${#temp_f}`
until [ ${c} = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done
[ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]] && temp_f_disp=$(IDS_NUMBER_FORMAT ${temp_f} 0) || temp_f_disp=${temp_f}
if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then
lclr="${idsCL[Yellow]}"
lmd="WARNING "
elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ]; then
lclr="${idsCL[LightRed]}"
lmd="CRITICAL"
if [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then
temp_f=$(CHECKTEMPSENSOR ${SENSOR})
[ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]] && temp_f_disp=$(IDS_NUMBER_FORMAT ${temp_f} 0) || temp_f_disp=${temp_f}
if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then
lclr="${idsCL[Yellow]}"
lmd="WARNING "
elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ]; then
lclr="${idsCL[LightRed]}"
lmd="CRITICAL"
else
lclr="${idsCL[Green]}"
lmd="Normal "
fi
c=0; spct=''; [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]] && spc1=`expr 5 - ${#temp_f}` || spc1=`expr 6 - ${#temp_f}`
until [ ${c} = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done
reading="${lclr}${lmd}${spct}${temp_f_disp}${GAUGESH}"
else
lclr="${idsCL[Green]}"
lmd="Normal "
temp_f=""
lclr="${idsCL[Yellow]}"
lmd=""
reading="${idsCL[Yellow]}Sensor Offline"
fi
reading="${lclr}${lmd}${spct}${temp_f_disp}${GAUGESH}"
echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${reading}${idsCL[Default]}"
if [ "${avgdays}" != "noavg" ]; then
@@ -158,25 +165,25 @@ CHECKTEMP(){
else
echo -e "${idsCL[Default]}"
fi
else
if [ "${avgdays}" != "noavg" ]; then
average=$(AVERAGETEMP ${SENSOR} ${avgdays})
([ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]) && average_disp=$(IDS_NUMBER_FORMAT ${average}) || average_disp=${average}
c=0; spca=''; spc1=`expr 6 - ${#average_disp}`; until [ ${c} = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
if [ "${average_disp}" == "" ]; then
averagedisp="${idsCL[Green]}"
elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
averagedisp="${idsCL[Yellow]}${average}"
elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
averagedisp="${idsCL[LightRed]}${average_disp}"
else
averagedisp="${idsCL[Green]}${average_disp}"
fi
echo -e "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${idsCL[Yellow]}Sensor Offline /${spca}${averagedisp}${GAUGESH}${idsCL[Default]}"
else
echo -e "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${idsCL[Yellow]}Sensor Offline${idsCL[Default]}"
fi
fi
# else
# if [ "${avgdays}" != "noavg" ]; then
# average=$(AVERAGETEMP ${SENSOR} ${avgdays})
# ([ "${PW_SENSOR_TYPE[${SENSOR}]}" == "system" ] && [[ "${SENSOR}" = *"FAN"* ]]) && average_disp=$(IDS_NUMBER_FORMAT ${average}) || average_disp=${average}
# c=0; spca=''; spc1=`expr 6 - ${#average_disp}`; until [ ${c} = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
# if [ "${average_disp}" == "" ]; then
# averagedisp="${idsCL[Green]}"
# elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
# averagedisp="${idsCL[Yellow]}${average}"
# elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
# averagedisp="${idsCL[LightRed]}${average_disp}"
# else
# averagedisp="${idsCL[Green]}${average_disp}"
# fi
# echo -e "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${idsCL[Yellow]}Sensor Offline /${spca}${averagedisp}${GAUGESH}${idsCL[Default]}"
# else
# echo -e "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${idsCL[Yellow]}Sensor Offline${idsCL[Default]}"
# fi
# fi
echo
last_sensor=${SENSOR}
fi