thinknagent 0.1.27 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/metrics.js +10 -4
  2. package/package.json +1 -1
package/lib/metrics.js CHANGED
@@ -97,10 +97,16 @@ class MetricsPoller {
97
97
  processes: {
98
98
  total: procs.all,
99
99
  running: procs.running,
100
- top: (procs.list || [])
101
- .sort((a, b) => b.pcpu - a.pcpu)
102
- .slice(0, 5)
103
- .map(p => ({ pid: p.pid, name: p.name, cpu: p.pcpu, mem: p.pmem })),
100
+ top: (() => {
101
+ const list = procs.list || [];
102
+ // Filter out idle Linux kernel threads (PID 2, kthreadd, rcu, pool_workqueue, etc. which consume 0 user memory and 0 CPU)
103
+ const nonKernel = list.filter(p => p && p.pid > 1 && (p.pmem > 0 || p.pcpu > 0) && p.name !== 'kthreadd' && !p.name.startsWith('R-') && !p.name.startsWith('kworker') && p.name !== 'pool_workqueue_release');
104
+ const candidates = nonKernel.length > 0 ? nonKernel : list.filter(p => p && p.pid > 0);
105
+ return candidates
106
+ .sort((a, b) => ((b.pcpu || 0) - (a.pcpu || 0)) || ((b.pmem || 0) - (a.pmem || 0)))
107
+ .slice(0, 5)
108
+ .map(p => ({ pid: p.pid, name: p.name, cpu: p.pcpu || 0, mem: p.pmem || 0 }));
109
+ })(),
104
110
  },
105
111
  apm: {
106
112
  nodeName: require('os').hostname(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinknagent",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "ThinkNCollab server agent & MCP server — metrics, logs, alerts, shell bridge, AI planning",
5
5
  "main": "lib/agent.js",
6
6
  "author": "ThinkNCollab Team <raman@thinkncollab.com>",