Update temp.inc.sh

This commit is contained in:
2024-01-27 14:33:00 -06:00
parent 9996a418af
commit 22aa6f44da

View File

@@ -207,10 +207,15 @@ CHECKTEMPSENSOR(){
temp_crit=`echo $(bc <<< "scale=2; (${4}*1.8+32)/1") | awk '{print int($1+0.5)}'`
elif [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then
TIMEOUT=0
if [ "${1}" == "Powerwall-CPU-Usage" ]; then
temp_c=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) | sed -e 's/%//g')
if ! temp_c=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) | sed -e 's/%//g') ; then
TIMEOUT=1
fi
else
temp_c=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "/opt/idssys/defaults/get-data.sh cpu-usage")
if ! temp_c=$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "/opt/idssys/defaults/get-data.sh cpu-usage") ; then
TIMEOUT=1
fi
fi
fi
@@ -277,6 +282,8 @@ CHECKTEMPSENSOR(){
echo -en "${idsCL[Default]}${spc}[${spcw}${idsCL[Yellow]}${temp_warn_disp}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit_disp}${GAUGESH}=>${idsCL[Default]} ]"
[ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ] && [[ "${1}" != *"-Probe" ]] && echo -e " - $(echo ${INFO} | jq -r '.device0 .obs[].timestamp')" || echo
fi
elif [ ${TIMEOUT} -eq 1 ]; then
echo -e "${idsCL[Yellow]}Sensor Timeout${idsCL[Default]}"
else
echo -e "${idsCL[Yellow]}Sensor Offline${idsCL[Default]}"
fi