forked from mtusi2026/mtusi2026lab6
ЛР 6 — БПИ2302 — Нурлыгаянова — на 3
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""30s closed-loop workload plus sampled Docker CPU/RAM (not peak measurement)."""
|
||||
import json
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
with (root/'evidence'/'load.txt').open('w') as output:
|
||||
process = subprocess.Popen([sys.executable,'tests/load.py','--base-url','http://localhost:18086',
|
||||
'--duration','30','--concurrency','4','--output','evidence/load.json'],cwd=root,stdout=output,stderr=subprocess.STDOUT)
|
||||
samples = []
|
||||
while process.poll() is None:
|
||||
raw = subprocess.check_output(['docker','stats','--no-stream','--format','{{json .}}'],text=True)
|
||||
samples.append({'unix':time.time(),'containers':[json.loads(line) for line in raw.splitlines() if 'mtusi-lab6-' in line]})
|
||||
time.sleep(3)
|
||||
if process.returncode:
|
||||
raise SystemExit(process.returncode)
|
||||
info = json.loads(subprocess.check_output(['docker','info','--format','{{json .}}'],text=True))
|
||||
result = {'host':platform.platform(),'docker':{'os':info['OperatingSystem'],'cpus':info['NCPU'],'memory_bytes':info['MemTotal']},
|
||||
'note':'CPU/RAM snapshots during workload, not peaks; Docker Desktop shared with other local services.', 'samples':samples}
|
||||
(root/'evidence'/'resources.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n')
|
||||
print('PASS: evidence/load.json and evidence/resources.json')
|
||||
Reference in New Issue
Block a user