Skip to content

Reported CPU usage out of range >100 and <0 on virtual machines #1007

@mtullmann1

Description

@mtullmann1

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:

  1. used function: si.processes();
  2. code snippet: I hope the code in the next section will be enough.
  3. 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();

  1. See output/error
Image Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions