SunilWang / node-os-utils

OS Utils - An operating system utility library.
https://www.npmjs.com/package/node-os-utils
MIT License
126 stars 19 forks source link

fix: netstat inOut interval #30

Closed chaos-zhu closed 2 years ago

chaos-zhu commented 2 years ago

I think inputMb and outputMb should not be affected by interval. Please correct any mistakes

// Compute input output
metrics[oldStats[i].interface]['inputMb'] = parseFloat(((newStats[i].inputBytes - oldStats[i].inputBytes) / interval * 1000 / 1000000).toFixed(2))
metrics[oldStats[i].interface]['outputMb'] = parseFloat(((newStats[i].outputBytes - oldStats[i].outputBytes) / interval * 1000 / 1000000).toFixed(2))

// When I get it every 10 seconds, it's no longer accurate
netstat.inOut(10*1000) // 10s