Phase 17: multi-host dashboard (0.19.0)
The dashboard now renders a stacks-with-usage table per host: the local host
plus a section for each registered agent (online dot + offline notice), reusing
the same CPU/memory meters and inline start/stop/restart actions.
- agent_app.py: GET /agent/stacks/stats (reuses stats_service); /agent/system
now also returns cpu_cores + mem_total for remote meter references.
- routers/agents.py: proxy GET /api/agents/{id}/stacks/stats (declared before
/{agent_id}/stacks/{stack_id}).
- Frontend: agentsApi.system + stackStats; Dashboard refactored into a shared
StacksTable used by the local section and a per-agent AgentDashboardSection.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
56450efd82
commit
8fbacd200a
+21
-1
@@ -43,6 +43,7 @@ from services import (
|
||||
file_service,
|
||||
image_service,
|
||||
network_service,
|
||||
stats_service,
|
||||
update_service,
|
||||
volume_service,
|
||||
)
|
||||
@@ -60,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.18.0"
|
||||
AGENT_VERSION = "0.19.0"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -158,6 +159,18 @@ def _hostname() -> str:
|
||||
return os.uname().nodename
|
||||
|
||||
|
||||
def _mem_total() -> int:
|
||||
for base in (settings.HOST_PROC_PATH, "/proc"):
|
||||
try:
|
||||
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
|
||||
except OSError:
|
||||
continue
|
||||
return 0
|
||||
|
||||
|
||||
def _system_info() -> dict:
|
||||
docker_version = ""
|
||||
host_os = ""
|
||||
@@ -175,6 +188,8 @@ def _system_info() -> dict:
|
||||
"hostname": _hostname(),
|
||||
"docker_version": docker_version,
|
||||
"host_os": host_os,
|
||||
"cpu_cores": os.cpu_count() or 0,
|
||||
"mem_total": _mem_total(),
|
||||
"containers_running": running,
|
||||
"containers_total": total,
|
||||
}
|
||||
@@ -207,6 +222,11 @@ def list_stacks() -> list[dict]:
|
||||
return [_summary(sid) for sid in compose_service.discover_stacks()]
|
||||
|
||||
|
||||
@app.get("/agent/stacks/stats", dependencies=[Depends(verify_token)])
|
||||
def stacks_stats() -> dict:
|
||||
return stats_service.stack_stats()
|
||||
|
||||
|
||||
@app.get("/agent/stacks/{stack_id}", dependencies=[Depends(verify_token)])
|
||||
def get_stack(stack_id: str) -> dict:
|
||||
directory = compose_service.stack_dir(stack_id)
|
||||
|
||||
Reference in New Issue
Block a user