From 5c9df194efe6fe13f9d57594cc5ab0b114d20eaf Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 19 Jul 2025 10:09:36 -0500 Subject: [PATCH] Update power.inc.sh --- inc/power.inc.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inc/power.inc.sh b/inc/power.inc.sh index c504ae54..bc341363 100644 --- a/inc/power.inc.sh +++ b/inc/power.inc.sh @@ -17,6 +17,7 @@ AVERAGEPOWER(){ logsfound_watt=0; total_amp=0 total_watt=0 + echo "HERE: ${sensorid}-" while IFS=$'\t' read date amp watt ;do if [ "${amp}" != "" ] && [ "${amp}" != "0" ] && [ "${amp}" != "NULL" ] && [[ "${amp}" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then total_amp=$(bc <<< "scale=2; ${total_amp}+${amp}") @@ -26,6 +27,8 @@ AVERAGEPOWER(){ total_watt=$(bc <<< "scale=2; ${total_watt}+${watt}") ((logsfound_watt++)) fi + echo "A:${amp}-${total_amp}=${average_amp}" + echo "W:${watt}-${total_watt}=${average_watt}" done < <(${mysql_conn} -se "USE servermonitor; SELECT date,amp,watt from power_data WHERE sensorid=${sensorid} AND date >= DATE_SUB(NOW(), INTERVAL ${interval}) ORDER BY id DESC;") if [ "${logsfound_watt}" != "0" ]; then average_amp=$(bc <<< "scale=2; ${total_amp}/${logsfound_amp}") @@ -34,7 +37,6 @@ AVERAGEPOWER(){ average_amp=0 average_watt=0 fi - # echo "HERE: ${sensorid}-" echo "${average_amp}~${average_watt}" else logsfound=0; @@ -530,7 +532,7 @@ CHECKPOWER(){ [ ${REPORT} -eq 0 ] && echo -e "${spc3}${VOLT}'V${idsCL[Default]}" else echo -en "${idsCL[Yellow]} Calculating ${avgdays_disp} Average ... " - # AVERAGEPOWER ${PW_POWERSENSOR_ID[${mSENSOR}]} ${avgdays} both + AVERAGEPOWER ${PW_POWERSENSOR_ID[${mSENSOR}]} ${avgdays} both avg=$(AVERAGEPOWER ${PW_POWERSENSOR_ID[${mSENSOR}]} ${avgdays} both) AMP_avg=$(echo ${avg} | cut -d'~' -f 1) WATT_avg=$(echo ${avg} | cut -d'~' -f 2)