From 397ec405a079d2a3eeb345155369d86a90abc565 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 24 May 2026 11:25:27 -0400 Subject: [PATCH] =?UTF-8?q?varaverk:=20memory=20card=20=E2=80=94=20top=205?= =?UTF-8?q?=20procs=20by=20RSS=20as=20horizontal=20strip=20under=20total?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/varaverk/include/monitor.php | 14 ++++++++++++ .../emhttp/plugins/varaverk/pages/monitor.php | 22 ++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php b/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php index 06a5483..3db3951 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/include/monitor.php @@ -145,6 +145,19 @@ function vv_memory_breakdown(): array { $freeKb = max(0, $mem['MemAvailable'] ?? 0); $systemKb = max(0, $totalKb - $freeKb - $arcKb - $dockerKb - $vmKb); + // Top processes by RSS — group same-named procs, take top 5 + $grouped = []; + $psOut = shell_exec("ps -eo comm,rss --sort=-rss 2>/dev/null | tail -n +2 | head -40") ?: ''; + foreach (explode("\n", trim($psOut)) as $line) { + $parts = preg_split('/\s+/', trim($line), 2); + if (count($parts) === 2 && is_numeric($parts[1]) && (int)$parts[1] > 0) + $grouped[$parts[0]] = ($grouped[$parts[0]] ?? 0) + (int)$parts[1]; + } + arsort($grouped); + $topProcs = []; + foreach (array_slice($grouped, 0, 5, true) as $name => $kb) + $topProcs[] = ['name' => $name, 'kb' => $kb]; + return [ 'total_kb' => $totalKb, 'system_kb' => $systemKb, @@ -152,6 +165,7 @@ function vv_memory_breakdown(): array { 'zfs_kb' => $arcKb, 'docker_kb' => $dockerKb, 'free_kb' => $freeKb, + 'top_procs' => $topProcs, ]; } diff --git a/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php b/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php index 119b905..35d4a0a 100644 --- a/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php +++ b/Plugin/usr/local/emhttp/plugins/varaverk/pages/monitor.php @@ -260,24 +260,16 @@ function vvRenderMemory(mem) { const usedPct = Math.round(usedKb / total * 100); const totalColor = usedPct >= 85 ? '#f44336' : usedPct >= 65 ? '#ff9800' : '#ccc'; - const buckets = [ - { label: 'System', kb: mem.system_kb ?? 0, color: VV_MEM_COLORS.system }, - { label: 'VM', kb: mem.vm_kb ?? 0, color: VV_MEM_COLORS.vm }, - { label: 'ZFS', kb: mem.zfs_kb ?? 0, color: VV_MEM_COLORS.zfs }, - { label: 'Docker', kb: mem.docker_kb ?? 0, color: VV_MEM_COLORS.docker }, - ]; - const top3 = [...buckets].sort((a, b) => b.kb - a.kb).slice(0, 3); - const top3Html = top3.map(b => - `
`+ - `${b.label} `+ - `${vvFmtGib(b.kb)}
` - ).join(''); + const procs = mem.top_procs ?? []; + const procStrip = procs.map(p => + `${p.name} ${vvFmtGib(p.kb)}` + ).join('·'); - let html = `
-
+ let html = `
+
${vvFmtGib(usedKb)} / ${vvFmtGib(total)}
-
${top3Html}
+
${procStrip}
`; html += vvMemRow('System', mem.system_kb ?? 0, total, VV_MEM_COLORS.system) + vvMemRow('VM', mem.vm_kb ?? 0, total, VV_MEM_COLORS.vm)