systeminformation
Processes and Services

In this section you will learn how to get information about current load, running processes and installed services:

For function reference and examples we assume, that we imported systeminformation as follows:

const si = require('systeminformation');

Current Load, Processes, Services

All functions in this section return a promise or can be called with a callback function (parameter cb in the function reference)

Getting correct stats values

In currentLoad() the results are calculated correctly beginning with the second call of the function. It is determined by calculating the difference of cpu ticks between two calls of the function.

The first time you are calling one of this functions, you will get the load since cpu uptime. The second time, you should then get statistics based on cpu ticks between the two calls ...

So basically, your code should look like this:

const si = require('systeminformation');

              setInterval(function() {
                  si.currentLoad().then(data => {
                      console.log(data);
                  })
              }, 1000)

Beginning with the second call, you get precise load values between the two calls.