Files
felhom.eu/documentation/audits/night-2026-09-25/tools/c_night.py
T

34 lines
1.8 KiB
Python

"""One simulated night on 9202: move W so the off-site job (and the chained update leg) fires in ~2 min, wait for the
leg's summary line, then capture the controller log of the night, the pages (both languages) and the data readback.
Evidence, not product. Usage: GUEST=9202 python3 c_night.py <label>"""
import sys, time, subprocess, datetime, json, os
import walk as w
w.login()
label = sys.argv[1]
EVD = w.EV + "/C/" + label
os.makedirs(EVD, exist_ok=True)
now = datetime.datetime.now()
start = now + datetime.timedelta(minutes=2)
W = (start - datetime.timedelta(minutes=105)).strftime("%H:%M")
leg_at = start.strftime("%H:%M")
w.say(f"night {label}: W={W} -> off-site job + update leg at {leg_at}")
r = subprocess.run(["python3", "movewin.py", W, EVD + "/window-moved.txt"], capture_output=True, text=True)
w.say(r.stdout[-400:])
since = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
t0 = time.time()
line = ""
while time.time() - t0 < 5400:
time.sleep(20)
out = w.guest(f"docker logs --since {since} felhom-controller 2>&1 | grep -F '[update-leg] update leg (' | tail -1")
if out.strip():
line = out.strip(); break
w.say("SUMMARY: " + (line or "NONE within 90 min"))
log = w.guest(f"docker logs --since {since} felhom-controller 2>&1 | grep -E 'update-leg|\\[stacks\\] update |offbox|scheduler\\] (Running|Job) .*offbox|UNDO|event app_update|quiesce' ")
open(EVD + "/controller-night.log", "w").write(log)
full = w.guest(f"docker logs --since {since} felhom-controller 2>&1")
open(EVD + "/controller-full.log", "w").write(full)
subprocess.run(["python3", "c1_state.py", EVD + "/pages-after.json"])
subprocess.run(["python3", "applines.py", EVD + "/app-lines.txt"])
subprocess.run(["python3", "seedread.py", "read", label + " (after the leg)"])
open(EVD + "/runner.log", "w").write("\n".join(w.LOG) + "\n")