[英]Why does calling iostat from a node.js app give me old info?
I am calling iostat from a node.js app like this: 我从这样的node.js应用程序调用iostat:
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.
但是,我得到的输出包含无效信息,特别是在一秒钟内写入的数据量-无论磁盘发生什么情况,它始终约为0.30MB / s。
Launching iostat
from the terminal gives me a different figure and corresponds with the amount of data I'm writing to the disk. 从终端启动
iostat
会给我一个不同的数字,并且与我正在写入磁盘的数据量相对应。
What am I doing wrong? 我究竟做错了什么?
Found the solution - turns out iostat gives you stats since booting the machine on its first run. 找到了解决方案-事实证明iostat自首次启动计算机以来就为您提供了统计信息。 That's why I was seeing pretty much the same information every time, since I was calling it only once.
这就是为什么我每次都看到几乎相同的信息的原因,因为我只调用了一次。
Lesson - RTFM. 课-RTFM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.