diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-09 19:17:29 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-09 19:17:29 +0100 |
| commit | 67e64e964a85562300b463378f0e260d6978867f (patch) | |
| tree | cb706f2142823ca436d301d8b7a2af27e88231c1 /deckit/modules | |
| parent | 796407233383e7bf4825f671d84fbe71279488a6 (diff) | |
| download | deck-it-67e64e964a85562300b463378f0e260d6978867f.tar.gz deck-it-67e64e964a85562300b463378f0e260d6978867f.zip | |
feat: build VM card shows the real stats dashboard
Diffstat (limited to 'deckit/modules')
| -rw-r--r-- | deckit/modules/sbbuilder.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/deckit/modules/sbbuilder.py b/deckit/modules/sbbuilder.py index 41f3a14..13552a1 100644 --- a/deckit/modules/sbbuilder.py +++ b/deckit/modules/sbbuilder.py @@ -1,7 +1,8 @@ -"""sb-builder build progress, read-only over ssh. +"""sb-builder build state, read-only over ssh. -The build VM's `sbb-remote jobs` already returns JSON; this module runs it over -the configured ssh host alias and relays it. Nothing here writes to the VM. +`sbb-remote stats` carries the dashboard: VM load, uptime, memory, disk, package +counts, orphans, slackrepo results and overlay pulls. `jobs` adds the recent +build list. Both run over one ssh connection and arrive as two JSON objects. """ import json @@ -10,7 +11,7 @@ import subprocess from ..module import Module -def _run(cmd, timeout=5): +def _run(cmd, timeout=8): try: return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout).stdout except (OSError, subprocess.TimeoutExpired): @@ -24,13 +25,16 @@ def make(cfg: dict) -> Module: def state(): try: out = run(["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=4", - host, "sbb-remote", "jobs"]) + host, "sbb-remote stats; sbb-remote jobs"]).lstrip() except OSError: return {"offline": True} try: - data = json.loads(out) + decoder = json.JSONDecoder() + stats, end = decoder.raw_decode(out) + jobs, _ = decoder.raw_decode(out[end:].lstrip()) except (ValueError, TypeError): return {"offline": True} - return {"offline": False, "jobs": data.get("jobs", [])} + return {"offline": False, "stats": stats, + "jobs": jobs.get("jobs", []) if isinstance(jobs, dict) else []} return Module(name="sbbuilder", title="Build VM", state=state) |
