Update powerwall.sh

This commit is contained in:
2023-12-03 15:26:01 -06:00
parent 122c8a975d
commit c271bd2637

View File

@@ -163,9 +163,9 @@ CHECKTEMPSENSOR(){
elif [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then
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))
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')
else
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "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)")
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "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'")
fi
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit
@@ -190,13 +190,13 @@ CHECKTEMPSENSOR(){
fi
fi
# if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then
# ([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}"
# elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ]; then
# ([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}"
# else
# ([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Green]}Normal ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Green]}Normal ${spct}${temp_f}"
# fi
if [ $(bc -l <<< "${temp_f} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_f} < ${temp_crit}") -eq 1 ]; then
([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_f}"
elif [ $(bc -l <<< "${temp_f} >= ${temp_crit}") -eq 1 ]; then
([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Red]}CRITICAL${spct}${temp_f}"
else
([ "${average}" != "" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]) && echo -en "${idsCL[Green]}Normal ${spct}${temp_f}'F /${spca}${averagedisp}${idsCL[Default]}" || echo -en "${idsCL[Green]}Normal ${spct}${temp_f}"
fi
[ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ] && echo -en "%${idsCL[Default]}" || echo -en "'F${idsCL[Default]}"
tmp="${spct}${temp_f}"