From 22aa6f44daf30165b8cb08a9b96f3384ddc79d59 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 27 Jan 2024 14:33:00 -0600 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 05af9414..1bd830c5 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -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