Update powerwall.sh
This commit is contained in:
@@ -137,6 +137,7 @@ AVERAGETEMP(){
|
|||||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
|
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
|
||||||
entityid=($(${mysql_conn} -e "SELECT id FROM servermonitor.entities WHERE BINARY name='${3}' AND sensorid='${sensorid}'"))
|
entityid=($(${mysql_conn} -e "SELECT id FROM servermonitor.entities WHERE BINARY name='${3}' AND sensorid='${sensorid}'"))
|
||||||
entityid=${entityid[1]}
|
entityid=${entityid[1]}
|
||||||
|
echo "HERE: ${3} - ${entityid}"
|
||||||
WHERE="sensorid=${sensorid} AND entity=${entityid}"
|
WHERE="sensorid=${sensorid} AND entity=${entityid}"
|
||||||
else
|
else
|
||||||
WHERE="sensorid=${sensorid}"
|
WHERE="sensorid=${sensorid}"
|
||||||
@@ -145,8 +146,7 @@ AVERAGETEMP(){
|
|||||||
while IFS=$'\t' read date sensorid temp hum ;do
|
while IFS=$'\t' read date sensorid temp hum ;do
|
||||||
temptotal=$(bc <<< "scale=2; ${temptotal}+${temp}")
|
temptotal=$(bc <<< "scale=2; ${temptotal}+${temp}")
|
||||||
((logsfound++))
|
((logsfound++))
|
||||||
done < <(${mysql_conn} -se "USE servermonitor; SELECT date,sensorid,temp,hum from sensor_data WHERE ${WHERE} AND date BETWEEN DATE_SUB(DATE(NOW()), INTERVAL ${daysback} DAY) AND NOW() ORDER BY id DESC;")
|
done < <(${mysql_conn} -se "USE servermonitor; SELECT date,sensorid,entity,temp,hum from sensor_data WHERE ${WHERE} AND date BETWEEN DATE_SUB(DATE(NOW()), INTERVAL ${daysback} DAY) AND NOW() ORDER BY id DESC;")
|
||||||
echo "USE servermonitor; SELECT date,sensorid,temp,hum from sensor_data WHERE ${WHERE} AND date BETWEEN DATE_SUB(DATE(NOW()), INTERVAL ${daysback} DAY) AND NOW() ORDER BY id DESC;"
|
|
||||||
average=$(bc <<< "scale=2; ${temptotal}/${logsfound}")
|
average=$(bc <<< "scale=2; ${temptotal}/${logsfound}")
|
||||||
echo ${average}
|
echo ${average}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user