简体   繁体   中英

Why does calling iostat from a node.js app give me old info?

I am calling iostat from a node.js app like this:

var exec = require('child_process').exec;

exec('iostat -md', function(err, stdout, stderr) {
    console.log(stdout);
  });

I decided to test this and ran the file, while writing lots of data to the disk. However, the output I get contains invalid information, specifically the amount of data written in a second - it's always around 0.30MB/s, no matter what's happening with the disk.

Launching iostat from the terminal gives me a different figure and corresponds with the amount of data I'm writing to the disk.

What am I doing wrong?

Found the solution - turns out iostat gives you stats since booting the machine on its first run. That's why I was seeing pretty much the same information every time, since I was calling it only once.

Lesson - RTFM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM