Dashboard: per-host resource overview bar (0.20.0)

The dashboard resource bar (CPU cores, memory used/total, containers, Docker
version) is now rendered per host instead of once for the local host — each
host section (local + each agent) shows its own bar above its stacks table.

- agent_app.py: _system_info() now also returns mem_used (from meminfo
  available), alongside the cpu_cores/mem_total added in 0.19.0.
- Frontend: extracted a ResourceBar component used by the local section and each
  AgentDashboardSection; AgentSystem type gained mem_used.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
menzelj
2026-06-08 13:22:27 +00:00
co-authored by Claude Opus 4.8
parent 8fbacd200a
commit eb9ffd0b0d
6 changed files with 80 additions and 35 deletions
+17 -6
View File
@@ -61,7 +61,7 @@ def _map_docker(exc: DockerError):
raise HTTPException(status_code=code, detail=exc.detail or exc.error)
raise exc # falls through to the global 502 DockerError handler
AGENT_VERSION = "0.19.0"
AGENT_VERSION = "0.20.0"
# --------------------------------------------------------------------------- #
@@ -159,16 +159,25 @@ def _hostname() -> str:
return os.uname().nodename
def _mem_total() -> int:
def _mem_info() -> tuple[int, int]:
"""Return (total_bytes, used_bytes) from meminfo (used = total - available)."""
for base in (settings.HOST_PROC_PATH, "/proc"):
try:
vals: dict[str, int] = {}
with open(os.path.join(base, "meminfo"), "r", encoding="utf-8") as fh:
for line in fh:
if line.startswith("MemTotal:"):
return int(line.split()[1]) * 1024 # kB -> bytes
parts = line.split(":")
if len(parts) == 2 and parts[0] in ("MemTotal", "MemAvailable", "MemFree"):
try:
vals[parts[0]] = int(parts[1].split()[0]) * 1024 # kB -> bytes
except ValueError:
pass
total = vals.get("MemTotal", 0)
available = vals.get("MemAvailable", vals.get("MemFree", 0))
return total, max(total - available, 0)
except OSError:
continue
return 0
return 0, 0
def _system_info() -> dict:
@@ -184,12 +193,14 @@ def _system_info() -> dict:
total = info.get("Containers", 0)
except DockerError as exc:
docker_version = f"unavailable ({exc.error})"
mem_total, mem_used = _mem_info()
return {
"hostname": _hostname(),
"docker_version": docker_version,
"host_os": host_os,
"cpu_cores": os.cpu_count() or 0,
"mem_total": _mem_total(),
"mem_total": mem_total,
"mem_used": mem_used,
"containers_running": running,
"containers_total": total,
}
+1 -1
View File
@@ -55,7 +55,7 @@ async def lifespan(app: FastAPI):
schedule_task.cancel()
app = FastAPI(title="StackPilot", version="0.19.0", lifespan=lifespan)
app = FastAPI(title="StackPilot", version="0.20.0", lifespan=lifespan)
app.add_middleware(
CORSMiddleware,