#!/usr/bin/env python3 """Local status page data. Does not call systemctl, attach XDP, or load seccomp.""" import json import socket from pathlib import Path ROOT = Path(__file__).resolve().parents[1] EVENTS = ROOT / "services" / "lane_evidence" / "vault" / "events.log" SMOKE = ROOT / "debug" / "smoke-result.json" PORTS = { "accounts": 8081, "bucket": 8082, "dashboard": 8083, } def port_open(port: int) -> bool: s = socket.socket() s.settimeout(0.2) try: return s.connect_ex(("127.0.0.1", port)) == 0 finally: s.close() def main() -> None: lines = [] if EVENTS.exists(): lines = EVENTS.read_text(encoding="utf-8", errors="replace").splitlines()[-12:] smoke = {} if SMOKE.exists(): smoke = json.loads(SMOKE.read_text()) status = { "accounts_8081": "open" if port_open(PORTS["accounts"]) else "closed", "bucket_8082": "open" if port_open(PORTS["bucket"]) else "closed", "dashboard_8083": "open" if port_open(PORTS["dashboard"]) else "closed", "evidence_broker": "importable" if smoke.get("evidence_broker") == "pass" else smoke.get("evidence_broker", "not_smoked"), "events_log_tail": lines, "smoke": smoke, } print(json.dumps(status, indent=2)) if __name__ == "__main__": main()