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

+52 -3
View File
@@ -73,6 +73,54 @@ The validation fixture uses this switch and does not connect to the NUC.
[PerfMon listener documentation](https://jmeter-plugins.org/wiki/PerfMon/),
[agent metrics/protocol](https://github.com/undera/perfmon-agent).
## Live Shelly power in JMeter
Every scenario, including idle, contains one **Shelly live power** thread. It polls
`http://192.168.1.44/rpc/Switch.GetStatus?id=0` every five seconds directly from
JMeter, independently of simulated users. There is no cloud dependency and no
post-run network transfer. No switch/set/reset commands are sent.
`shelly.csv` is written while JMeter runs, with timestamps, request status,
`shelly_power_watts`, `shelly_voltage_volts`, `shelly_current_amps` and cumulative
`shelly_energy_wh`. Raw readings include warmup. `shelly-measured.csv` brackets only
the measured interval, interpolating its boundaries; `run.json` includes mean watts,
integrated joules/kWh and the counter's Wh delta converted to joules/kWh.
The timestamp is approximated by each polling request's midpoint on this computer.
Meter requests are excluded from the application's request-rate and latency summary.
JMeter's overall console summary includes meter polls; use `run.json` and
`measured.csv` for the application-only figures.
Power integration uses trapezoids. Counter deltas provide a separate cross-check;
the device's counter update granularity can make short runs report little or no
counter change despite nonzero power. Both boundary interpolation and meter accuracy
limit precision; this does not claim calibration. The plug measures what is connected
to its outlet, including the NUC's power-adapter losses. Connect only the intended
measured equipment. Its internal temperature is **not the NUC CPU temperature**.
The runner defaults to this plug and checks its status before starting. Override with
`--shelly-host`, `--shelly-port`, `--shelly-switch-id` or `--shelly-interval-ms`.
There is a short unmeasured drain after the four-hour window to obtain its closing
boundary. Missing samples, long gaps, failed polls and counter resets invalidate the
power measurement; they are not treated as zero watts. `--no-shelly` is for isolated
workflow testing, and records that power monitoring was disabled. The current plug
has authentication disabled; authenticated device access is not yet implemented.
The runner configures JMeter's `sample_variables` so the numeric columns are saved.
For a manual GUI/CLI launch, pass:
```bash
-Jsample_variables=shelly_power_watts,shelly_voltage_volts,shelly_current_amps,shelly_energy_wh
```
Use the runner for experiment timing, summaries and completeness checks. A new
power-monitoring-only check can be run without application requests:
```bash
python3 tools/energy-jmeter/verify-shelly.py --host 192.168.1.44 --output tools/energy-jmeter/results/shelly-check-new
```
[Shelly switch status and energy units](https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Switch/).
## 1. Prepare distinct test accounts (outside measurement)
The installer initially supplies only one ordinary patient account. Use distinct
@@ -158,7 +206,7 @@ replaced. Do not use a partial/failed run as a successful four-hour measurement.
## 3. Run a full experiment
Start the external power recording **before** this command, on the NUC only:
Ensure the NUC is powered through the Shelly plug at **192.168.1.44**, then run:
```bash
python3 tools/energy-jmeter/run.py mixed --host 192.168.1.125 --ca tools/energy-jmeter/.private/healthapp-ca.crt --users-file tools/energy-jmeter/.private/dataset/users.csv --users 100 --warmup 1800 --duration 14400 --output tools/energy-jmeter/results/mixed-100-run1
@@ -190,7 +238,7 @@ p95 latency, random seed, timings and plan hash. JMeter CSV excludes response bo
request headers and passwords. The private runtime credential CSV is deleted at exit;
keep the whole result directory private and inspect logs before sharing.
JMeter measures HTTP performance, **not energy**. Export your meter's readings as
JMeter now collects the Shelly readings live and the runner calculates measured-window energy automatically. For another external meter, export its readings as
CSV with `timestamp,power_watts` (timezone-qualified ISO timestamps, increasing,
covering the full interval), then integrate only the measured four hours:
@@ -202,7 +250,7 @@ The tool interpolates interval edges and integrates watts using trapezoids. It r
joules, kWh, mean watts and joules per HTTP request. `--idle-watts VALUE` additionally
reports energy above the measured idle mean. A request is not a user session;
compare scenario/mix and achieved throughput when interpreting efficiency.
Raw meter data must be preserved; missing intervals cannot be repaired by JMeter.
Raw meter data must be preserved; missing intervals cannot be repaired by JMeter. The same rule applies to Shelly polls.
JMeter's stock HTTPS client trusts test certificates. The Python runner verifies the
provided CA and hostname during preflight; JMeter traffic itself remains encrypted
@@ -214,6 +262,7 @@ but does not provide certificate validation. Do not describe this as a TLS secur
python3 tools/energy-jmeter/generate-plans.py
python3 tools/energy-jmeter/verify-plans.py
python3 tools/energy-jmeter/verify-perfmon.py
python3 tools/energy-jmeter/verify-shelly.py
```
The validation script exercises every plan against an isolated local HTTPS contract