Stats Functions

Getting correct stats values

In fsStats(), disksIO() and networkStats() the results / sec. values (rx_sec, IOPS, ...) are calculated correctly beginning with the second call of the function. It is determined by calculating the difference of transferred bytes / IOs divided by the time between two calls of the function.

The first time you are calling one of this functions, you will get -1 for transfer rates. The second time, you should then get statistics based on the time between the two calls ...

So basically, if you e.g. need a values for network stats every second, your code should look like this:

const si = require('systeminformation');

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

Beginning with the second call, you get network transfer values per second.