Dashboard: per-host disk usage (0.21.0)
The per-host resource bar gained a Disk stat (used / total). The agent now reports disk_total/disk_used via shutil.disk_usage on its stacks dir (a host bind-mount), alongside the existing cpu/mem/containers fields; the local host uses the existing system info disk data. - agent_app.py: _disk_info() + disk_total/disk_used in _system_info(). - Frontend: ResourceBar gained diskUsed/diskTotal (5-column grid); AgentSystem type gained disk_total/disk_used. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
eb9ffd0b0d
commit
d1c63a329b
+16
-1
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from dataclasses import asdict
|
||||
|
||||
import tempfile
|
||||
@@ -61,7 +62,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.20.0"
|
||||
AGENT_VERSION = "0.21.0"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -180,6 +181,17 @@ def _mem_info() -> tuple[int, int]:
|
||||
return 0, 0
|
||||
|
||||
|
||||
def _disk_info() -> tuple[int, int]:
|
||||
"""Return (total_bytes, used_bytes) for the host disk backing the stacks dir."""
|
||||
for path in (settings.STACKS_DIR, "/"):
|
||||
try:
|
||||
usage = shutil.disk_usage(path)
|
||||
return usage.total, usage.used
|
||||
except OSError:
|
||||
continue
|
||||
return 0, 0
|
||||
|
||||
|
||||
def _system_info() -> dict:
|
||||
docker_version = ""
|
||||
host_os = ""
|
||||
@@ -194,6 +206,7 @@ def _system_info() -> dict:
|
||||
except DockerError as exc:
|
||||
docker_version = f"unavailable ({exc.error})"
|
||||
mem_total, mem_used = _mem_info()
|
||||
disk_total, disk_used = _disk_info()
|
||||
return {
|
||||
"hostname": _hostname(),
|
||||
"docker_version": docker_version,
|
||||
@@ -201,6 +214,8 @@ def _system_info() -> dict:
|
||||
"cpu_cores": os.cpu_count() or 0,
|
||||
"mem_total": mem_total,
|
||||
"mem_used": mem_used,
|
||||
"disk_total": disk_total,
|
||||
"disk_used": disk_used,
|
||||
"containers_running": running,
|
||||
"containers_total": total,
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ async def lifespan(app: FastAPI):
|
||||
schedule_task.cancel()
|
||||
|
||||
|
||||
app = FastAPI(title="StackPilot", version="0.20.0", lifespan=lifespan)
|
||||
app = FastAPI(title="StackPilot", version="0.21.0", lifespan=lifespan)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
||||
Reference in New Issue
Block a user