perf: stats poll via lichtgewicht /api/stats i.p.v. /containers-dashboard

De frontend haalde CPU/mem stats op via het zware /containers-dashboard
endpoint (Podman call + os.walk + systemctl subprocesses per container).
Nu gaat de stats poll via een nieuw /api/stats endpoint dat alleen de
bestaande in-memory cache teruggeeft (<5ms vs ~400ms).

- app_containers.py: /api/stats endpoint toegevoegd (cache direct return)
- app_containers.py: _STATS_SHOWN_NAMES bijgehouden per dashboard call
  (filtert infra/management containers eruit op basis van _dashboard_source)
- containers.js: pollContainersDashboardStatsOnce() gebruikt /api/stats

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 15:09:53 +01:00
parent e922cea167
commit f016c2bae0
2 changed files with 21 additions and 13 deletions
+5 -13
View File
@@ -261,27 +261,19 @@ async function pollContainersDashboardStatsOnce() {
if (containersDashboardStatsInFlight) return;
containersDashboardStatsInFlight = true;
try {
const containers = await api('/containers-dashboard', 'GET');
const list = Array.isArray(containers) ? containers : (containers?.containers || []);
const stats = await api('/stats', 'GET');
// totals per pod voor deze poll tick
const podCpu = new Map(); // podName -> cpuPct sum
const podMem = new Map(); // podName -> memBytes sum
const podMemPct = new Map(); // podName -> memPct sum
for (const c of (list || [])) {
const cname = normalizeContainerName((c?.Names && c.Names[0]) ? c.Names[0] : (c?.Names || c?.Name || c?.name || ''));
if (!cname) continue;
for (const [cname, s] of Object.entries(stats || {})) {
const key = cssSafeId(cname);
const cpuRaw = c?._dashboard_cpu;
const memBytesRaw = c?._dashboard_mem_usage;
const memPctRaw = c?._dashboard_mem_perc;
const cpuPct = Number(cpuRaw);
const memBytes = Number(memBytesRaw);
const memPct = Number(memPctRaw);
const cpuPct = Number(s?.cpu);
const memBytes = Number(s?.mem_usage);
const memPct = Number(s?.mem_perc);
const pod = containersC2P.get(cname);
if (pod) {