Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
how to get server cpu and memory and disk percentage in node.js
var os  = require('os-utils');
os.cpuUsage(function(v){
    console.log( 'os-utils CPU Usage (%): ' + v ); 
    // os-utils CPU Usage (%): 0.11180382377389864
});
os.cpuFree(function(v){
    console.log( 'os-utils CPU Free:' + v );
    // os-utils CPU Free:0.8876135425268373
});

var osu = require('node-os-utils')
var cpu = osu.cpu
cpu.usage()
.then(info => {
    console.log('node-os-utils cpu.usage '+info)
    // node-os-utils cpu.usage 11.53
})
cpu.free()
.then(info => {
    console.log('node-os-utils cpu.free '+ info)
    // node-os-utils cpu.free 88.47
})

it's so annoying. Why is the os-utils value different from the node-os-utils value? I need the CPU and disk memory values ​​of the server currently running node.js -Current CPU usage** (percent) -Available memory* (free/total) -Available disk space (free/total)

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Why is the os-utils value different from the node-os-utils value?

Because one is a percentage (a number between 0 and 100) and one is a number between 0 and 1.

(I would assume that multi-core systems may multiple the maximum number by the number of cores.)

The values are the same. They are just expressed in very slightly different terms.

about 4 years ago · Santiago Trujillo Report

0

It seems like os-utils package works well. Just format of percentage was given from 0 to 1, meaning 0 => 0% and 1 => 100% and so on.

About getting disk space volume info you can use package diskusage. You can check docs there https://www.npmjs.com/package/diskusage

const disk = require('diskusage');

// get disk usage. Takes mount point as first parameter
disk.check('/', function(err, info) {
    const freeInPercentage = info.free / info.total;
    const usedInPercentage = info.available / info.total;

    console.log(`free disk space: ${freeInPercentage * 100}%`);
    console.log(`used disk space: ${usedInPercentage * 100}%`);
});
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!