-
-
Notifications
You must be signed in to change notification settings - Fork 337
Description
Describe the bug
A clear and concise description of what the bug is.
I read Hyper-threading and System Time or Clock Drift could be an issue.
However I am not aware that native tools like Task Manager or Recourse Monitor have the same issue.
To Reproduce
Steps to reproduce the behavior:
- used function: si.processes();
- code snippet: I hope the code in the next section will be enough.
- start app / code
Since my code is way too large to focus, I wrote a smaller basic version of it.
Note: This code will only run 3 times and might not catch the issue fast since it is sometimes very
const si = require('systeminformation');
let iteration = 0;
const maxIterations = 3;
async function monitor() {
try {
const [processes] = await Promise.all([
si.processes()
]);
const totalCpuProc = processes.list.reduce((sum, p) => sum + (p.cpu || 0), 0);
console.log(`\n┌─────────────────────────────────────────────────────────────────────┐`);
console.log(`│ Iteration ${++iteration}/${maxIterations} - ${new Date().toLocaleTimeString().padEnd(52)}│`);
console.log(`├─────────────────────────────────────────────────────────────────────┤`);
console.log(`│ Total Processes: ${processes.all.toString().padEnd(51)}│`);
console.log(`│ Total CPU (sum): ${totalCpuProc.toFixed(2)}%`.padEnd(70) + '│');
console.log(`└─────────────────────────────────────────────────────────────────────┘`);
// Sort by CPU usage (descending)
const sortedProcs = [...processes.list].sort((a, b) => (b.cpu || 0) - (a.cpu || 0));
console.log(`\n┌──────────┬───────┬────────────┬─────────────────────────────────────┐`);
console.log(`│ PID │ CPU% │ Memory │ Name │`);
console.log(`├──────────┼───────┼────────────┼─────────────────────────────────────┤`);
sortedProcs.forEach(proc => {
const pid = (proc.pid || 0).toString().padEnd(8);
const cpu = (proc.cpu || 0).toFixed(1).padStart(5);
const mem = ((proc.memRss || 0) / 1024 / 1024).toFixed(1).padStart(7);
const name = (proc.name || '').substring(0, 36).padEnd(36);
console.log(`│ ${pid} │ ${cpu} │ ${mem} MB │ ${name}│`);
});
console.log(`└──────────┴───────┴────────────┴─────────────────────────────────────┘`);
} catch (error) {
console.error('Error:', error.message);
}
if (iteration < maxIterations) {
setTimeout(monitor, 3000);
} else {
console.log('\nTest complete!');
}
}
console.log('Process Monitor - All Processes (3s intervals)\n');
monitor();
- See output/error
Current Output
If applicable, add output to help explain your problem.
Expected behavior
A clear and concise description of what you expected to happen.
I would expect the same output as in other native tools like Task Manager or Resource Monitor, even inside a busy hypervisor.
Environment (please complete the following information):
- systeminformation package version:
- OS: Windows 11 and Debian 12 (both virtualized), seems to happen also in Docker Debian 12.
- Hardware: Intel Xeon Gold 6348
To get all needed environment information, please run the following command:
npx systeminformation info
┌─────────────────────────────────────────────────────────────────────────────────────────┐
│ SYSTEMINFORMATION Version: 5.27.11 │
└─────────────────────────────────────────────────────────────────────────────────────────┘
Operating System:
──────────────────────────────────────────────────────────────────────────────────────────
Platform : linux
Distro : Debian GNU/Linux
Release : 12
Codename : bookworm
Kernel : 6.1.0-39-amd64
Arch : x64
Hostname : VRA-TST-0037719
Codepage : UTF-8
Build :
System:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer : VMware, Inc.
Model : VMware7,1
Version : None
Virtual : true
CPU:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer : Intel
Brand : Xeon® Gold 6348
Family : 6
Model : 106
Stepping : 6
Speed : 2.6
Cores : 2
PhysicalCores : 2
PerformanceCores : 2
EfficiencyCores :
Processors : 2
Socket :
Additional context
Add any other context about the problem here.