Update powerwall.sh

This commit is contained in:
2023-12-03 17:09:38 -06:00
parent 35bc999a1d
commit dec59ee7e8

View File

@@ -17,7 +17,7 @@ VERBOSE=false
CHECKTEMP(){
start=`date +%s`
cw=45;
cw=25;
while [ $# -gt 0 ]; do
case "$1" in
-a|-avg) avgdays=${2};;
@@ -109,6 +109,7 @@ CHECKTEMP(){
CHECKTEMPSENSOR(){
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit
echo "${temp_warn} - ${temp_crit}"
if [ "${6}" != "noavg" ] && [ "${PW_SENSOR_TYPE[${1}]}" != "cpu" ]; then
[ "${6}" != "" ] && [[ "${6}" =~ ^[0-9]+$ ]] && avgdays=${6} || avgdays=3
if [ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ]; then
@@ -144,6 +145,7 @@ CHECKTEMPSENSOR(){
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')
else
echo "WOW"
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "/opt/idssys/defaults/get-data.sh cpu-usage")
fi
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn