perf(agent): read CPUPercent only on top-10 RAM processes, not all

Filter by RAM first (cheap), then call CPUPercent on just the 10 winners.
Reduces /proc reads from hundreds to 10 per interval.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-25 10:35:48 -05:00
co-authored by Claude Sonnet 4.6
parent ad531c6dfc
commit 71db59b005
2 changed files with 11 additions and 6 deletions
+6 -2
View File
@@ -162,13 +162,17 @@
<table class="w-full text-[10px]">
<thead><tr class="text-slate-400 border-b border-slate-200">
<th class="px-2 py-1 text-left">Proceso</th>
<th class="px-2 py-1 text-right">CPU%</th>
<th class="px-2 py-1 text-right">RAM</th>
</tr></thead>
<tbody>
<template x-for="p in (m.top_procs||[]).slice(0,10)" :key="p.pid">
<tr class="border-b border-slate-100 last:border-0">
<td class="px-2 py-1 font-mono truncate max-w-[120px]" x-text="p.nombre"></td>
<td class="px-2 py-1 text-right text-slate-600 font-mono font-bold" x-text="fmtMB(p.ram_mb)"></td>
<td class="px-2 py-1 font-mono truncate max-w-[90px]" x-text="p.nombre"></td>
<td class="px-2 py-1 text-right font-bold"
:class="p.cpu > 50 ? 'text-red-600' : p.cpu > 20 ? 'text-amber-600' : 'text-slate-600'"
x-text="p.cpu + '%'"></td>
<td class="px-2 py-1 text-right text-slate-500 font-mono" x-text="fmtMB(p.ram_mb)"></td>
</tr>
</template>
</tbody>