diff --git a/powerwall.sh b/powerwall.sh index 38bd6dbb..4518c40c 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -175,10 +175,33 @@ CHECKACV_SERVICE(){ last_battvolt=$BATTVOLT fi fi + sleep 10 done # & } +POWERLOGGER_SERVICE(){ + while true + do + outV=$(curl -s "http://10.10.0.61/stats.json" | jq '.outputs .outV') + outA=$(curl -s "http://10.10.0.61/stats.json" | jq '.outputs .outA') + inV=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .inV') + inA=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .inA') + battV=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .battV') + battA=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .xfA') + + QRY="USE servermonitor; INSERT INTO power_data (\`sensorid\`, \`volt\`, \`amp\`) VALUES ('2','${inV}','${inA}')" + echo $QRY + QRY="USE servermonitor; INSERT INTO power_data (\`sensorid\`, \`volt\`, \`amp\`) VALUES ('3','${outV}','${outA}')" + echo $QRY + QRY="USE servermonitor; INSERT INTO power_data (\`sensorid\`, \`volt\`, \`amp\`) VALUES ('4','${battV}','${battA}')" + echo $QRY + # ${mysql_conn} -e "${QRY}" + + sleep 5m + done +} + SHUTDOWN_SERVERS(){ touch $FOLDER/shutdown @@ -237,6 +260,17 @@ if [ ${action-x} ]; then CHECKACV_SERVICE fi ;; + powerlogger_service) + if [ "${2}" = "stop" ]; then + service_pid=`systemctl show --property MainPID --value ${SERVICE_NAME['powerlogger']}` + /usr/bin/pkill -P $service_pid + #/bin/systemctl stop $srvcname + #/usr/bin/killall bash + + else + POWERLOGGER_SERVICE + fi + ;; esac fi