Collect NUC host metrics live in all JMeter energy scenarios

This commit is contained in:
Steffen committed 2026-10-07 21:03:19 +02:00
1 parent 45a040f3a2
commit a69b9b2118
12 files changed
+602 -21

No files matched your search

+23 -2
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
"""Generate stock-JMeter plans; no plugins or application changes required."""
"""Generate JMeter plans with the PerfMon listener; no application changes required."""
from pathlib import Path
import xml.etree.ElementTree as E
from perfmon import METRICS
OUT = Path(__file__).parent / 'plans'
@@ -69,18 +70,38 @@ def record(t, correction=False):
request(t,'Remove duplicate test entry','DELETE','/api/observations/${observation_id}',status=204)
request(t,'Confirm removal','GET','/api/observations/${observation_id}',status=404)
for scenario in ['recording','review','correction','professional','mixed']:
for scenario in ['recording','review','correction','professional','mixed','idle']:
root=E.Element('jmeterTestPlan',version='1.2',properties='5.0',jmeter='5.6.3'); tree=E.SubElement(root,'hashTree')
plan, pt=element(tree,'TestPlan','TestPlanGui','HealthApp energy: '+scenario)
prop(plan,'TestPlan.comments','Synthetic closed-loop sessions; default duration four hours. Setup and energy-meter control are external.')
prop(plan,'TestPlan.functional_mode',False,'boolProp'); prop(plan,'TestPlan.serialize_threadgroups',False,'boolProp')
E.SubElement(E.SubElement(plan,'elementProp',name='TestPlan.user_defined_variables',elementType='Arguments',guiclass='ArgumentsPanel',testclass='Arguments',enabled='true'),'collectionProp',name='Arguments.arguments')
collector, _ = element(pt,'kg.apc.jmeter.perfmon.PerfMonCollector','kg.apc.jmeter.vizualizers.PerfMonGui','NUC live CPU RAM disk and network')
collector.set('enabled','true')
prop(collector,'filename','${__P(perfmon_file,perfmon.csv)}')
prop(collector,'ResultCollector.error_logging',False,'boolProp')
connections=E.SubElement(collector,'collectionProp',name='metricConnections')
for i,(kind,param,unit) in enumerate(METRICS):
row=E.SubElement(connections,'collectionProp',name=str(i))
for j,value in enumerate(['${__P(perfmon_host,192.168.1.125)}','${__P(perfmon_port,4444)}',kind,param]):prop(row,str(j),value)
group, gt=element(pt,'ThreadGroup','ThreadGroupGui','Users')
prop(group,'ThreadGroup.on_sample_error','stopthread')
loop=E.SubElement(group,'elementProp',name='ThreadGroup.main_controller',elementType='LoopController',guiclass='LoopControlPanel',testclass='LoopController',enabled='true')
prop(loop,'LoopController.continue_forever',False,'boolProp'); prop(loop,'LoopController.loops',-1)
for k,v in [('ThreadGroup.num_threads','${__P(users,1)}'),('ThreadGroup.ramp_time','${__P(ramp_seconds,60)}'),('ThreadGroup.duration','${__P(total_duration_seconds,16205)}'),('ThreadGroup.delay','0')]: prop(group,k,v)
prop(group,'ThreadGroup.scheduler',True,'boolProp'); prop(group,'ThreadGroup.same_user_on_next_iteration',True,'boolProp')
if scenario=='idle':
prop(group,'ThreadGroup.num_threads','1');prop(group,'ThreadGroup.ramp_time','0')
once, ot=element(gt,'OnceOnlyController','OnceOnlyControllerGui','Record idle measurement window')
script(ot,'JSR223Sampler','Idle timing', '''long start=System.currentTimeMillis()
long measurement=start+Long.parseLong(props.getProperty('warmup_seconds','1800'))*1000
long end=measurement+Long.parseLong(props.getProperty('duration_seconds','14400'))*1000
if (props.get('timeline_file')) new File(props.get('timeline_file')).text=groovy.json.JsonOutput.toJson([warmup_start_ms:start,measurement_start_ms:measurement,measurement_end_ms:end])
''')
pause,_=element(gt,'TestAction','TestActionGui','Idle wait; no application requests')
prop(pause,'ActionProcessor.action',1,'intProp');prop(pause,'ActionProcessor.target',0,'intProp');prop(pause,'ActionProcessor.duration','1000')
E.indent(root);E.ElementTree(root).write(OUT/(scenario+'.jmx'),encoding='utf-8',xml_declaration=True)
continue
headers, _=element(gt,'HeaderManager','HeaderPanel','JSON and bearer token')
coll=E.SubElement(headers,'collectionProp',name='HeaderManager.headers')
for name,value in [('Content-Type','application/json'),('Authorization','Bearer ${token}')]: