Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

cpu-stats

1.0.0 • Public • Published

cpu-stats

Dependency Status devDependency Status Build Status Coverage Status

Calls a callback with the current CPU utilisation status in percent per core.

var cpuStats = require('cpu-stats')
 
// the first argument is how long to sample for in ms.
// longer is more accurate but, you know, longer.
// if omitted, defaults to one second.
cpuStats(1000, function(error, result) {
  if(error) return console.error('Oh noes!', error) // actually this will never happen
 
  console.info(result)
})

Will output:

[
  { cpu: 14, user: 7, nice: 0, sys: 7, idle: 86, irq: 0 },
  { cpu: 3, user: 1, nice: 0, sys: 2, idle: 97, irq: 0 },
  { cpu: 9, user: 5, nice: 0, sys: 4, idle: 91, irq: 0 },
  { cpu: 2, user: 1, nice: 0, sys: 1, idle: 98, irq: 0 }
]

All numbers are in % and will probably not be integers.

cpu is a convenience addition of all activity per core minus idle time.

install

npm i cpu-stats

Downloadsweekly downloads

39

version

1.0.0

license

ISC

repository

githubgithub

last publish

collaborators

  • avatar