Collect Shelly plug power live in JMeter energy experiments

This commit is contained in:
Steffen committed 2026-10-07 22:12:58 +02:00
1 parent a69b9b2118
commit e50cf0a011
13 files changed
+634 -22

No files matched your search

+5 -1
View File
@@ -2,6 +2,7 @@
"""Verify metric decoding; optionally verify a live JMeter-to-agent connection."""
import argparse, csv, json, subprocess, tempfile, time
from pathlib import Path
import xml.etree.ElementTree as E
from perfmon import METRICS, check_agent, summarize
p=argparse.ArgumentParser();p.add_argument('--host');p.add_argument('--port',type=int,default=4444);p.add_argument('--output');a=p.parse_args()
with tempfile.TemporaryDirectory(prefix='healthapp-perfmon-unit-') as name:
@@ -26,7 +27,10 @@ if a.host:
if not a.output:p.error('--output is required for a live check')
check_agent(a.host,a.port)
out=Path(a.output).resolve();out.mkdir(parents=True,mode=0o700,exist_ok=False)
plan=Path(__file__).parent/'plans/idle.jmx'
document=E.parse(Path(__file__).parent/'plans/idle.jmx')
for group in document.iter('ThreadGroup'):
if group.get('testname')=='Shelly live power':group.set('enabled','false')
plan=out/'idle.jmx';document.write(plan)
cmd=[str(Path.home()/'.local/bin/jmeter'),'-n','-t',str(plan),'-l',str(out/'samples.csv'),'-j',str(out/'jmeter.log'),'-Jperfmon_host='+a.host,'-Jperfmon_port='+str(a.port),'-Jperfmon_file='+str(out/'perfmon.csv'),'-JjmeterPlugin.perfmon.interval=5000','-JjmeterPlugin.perfmon.useUDP=false','-Jjmeter.save.saveservice.autoflush=true','-Jwarmup_seconds=5','-Jduration_seconds=20','-Jtotal_duration_seconds=30','-Jtimeline_file='+str(out/'timeline.json')]
process=subprocess.Popen(cmd);saved_live=False
while process.poll() is None: