feat: live container stats on rows, a Stats tab and per-project totals #22
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/11-container-stats"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Live resource usage for running containers, read from the engine's stats stream (bollard
stats,stream: true).What's in it
docker stats: CPU = container CPU time / host CPU time × online CPUs (100% = one core), memory = usage minusinactive_file(cgroup v2) ortotal_inactive_file(v1). Rates come from counter deltas and drop to 0 when counters reset (restart). A stream that ends is retried every 2 s while the container is still wanted.statsscreenshot scene; README features and screenshots updated.Left out: totals in the tray tooltip (optional in the issue). It would mean streaming stats for every container while the window is closed, which works against "only while visible"; happy to add it as a follow-up if wanted.
Code:
src/stats.rs(parsing, history, session),ContainerModel.watchStats(ids, detailIds)+stats_jsonproperty,StatsView.qml,StatGraph.qml(Canvas sparkline).Tested
cargo fmt --check,clippy --all-targets -D warningswith and withoutmock,cargo build,cargo test(5 new tests: docker-stats math on a cgroup v2 frame, v1 names, first frame without CPU, rates/restart, history cap), all with Rust 1.100.0.docker stats --no-stream(busy-loop container ~90–99% CPU, postgres ~31 MB vs 30.15 MiB); stopped containers show "Not Running"; switching to Volumes closes the stat streams (socket count drops by one per running container).Screenshots (mock data)
Stats tab for a compose project (dark):

Light:

Figures on the container rows:

Closes #11
Review from Nye (posted on its behalf):
Review: PR #22 (container stats),
253c22f— Approve, no blocking findingsCI gates (Rust 1.100.0): fmt --check, clippy --all-targets -D warnings (with and without
mock), cargo test (10 pass), build --features mock: all pass.Real engine (Docker 26.1.5, cgroup v2):
docker stats --no-stream: busy loop 99–100% vs 99.24%; 1.9 MB vs 1.824 MiB; 4.2 MB vs 4 MiB; 434 kB vs 424 KiB. Compose row sums its services (6.1 MB = 1.9 + 4.2). Stats tab network and disk totals match NetIO/BlockIO (13 kB rx; 3.0 MB read / 67 MB written).--mock --show: rows and the shop Stats tab (graphs plus per-service rows) render like the screenshots. README and build.rs are updated.Non-blocking notes:
follow()opens a freshDocker::connect_with_local_defaults()per container. That's fine on a unix socket, but when #16 lands it must use the shared selected-engine client. Over ssh:// each client starts its own ssh master, so 33 containers would mean 33 ssh processes. Please carry this into #16.Entry::pushupdateslatestbut keeps the oldpoint. For one tick the totals are new and the rates are old.