Use require('loadavg-windows')
to enjoy os.loadavg()
on Windows OS (or force using custom implementation on any other OS).
Currently Node.js on Windows platform do not implements os.loadavg()
functionality - it returns [0,0,0]
- os.loadavg() returns [A, B, C]
- A - expect value different than 0 after few seconds.
- B - expect value different than 0 after first 5 minutes.
- C - expect value different than 0 after first 15 minutes.
- Requiring it on other operating systems have NO influence,
unless
require('loadavg-windows').enableCustomLoadavg()
called manually.
Just one line required to enjoy os.loadavg()
on Windows OS:
require('loadavg-windows');
setInterval( () => {
console.log( os.loadavg() );
}, 3000);
Can be activated on any other OS in case native version not working (on Windows OS it is enabled by default)
const { useCustomLoadavg } = require('loadavg-windows');
useCustomLoadavg();
Requires Node.js v4.8.7
npm install loadavg-windows
This is pure JavaScript, platform-independent implementation of os.loadavg()
that can be used on Windows system
(or any other system that for some reasons do not supports loadavg)
It uses only os.cpus()
for proper calculations.
Test of version [email protected]
- First chart demonstrates results during 4h runtime with sample every 21 seconds.
- Second chart is to check for memory leaks. Memory consumption includes also http server (no memory leaks).