Linux,监控文件的读取率
我有一个自定义应用程序,其中打开了一堆文件。我可以使用“lsof”查看进程打开的文件句柄,并且可以使用“watch -d 'ls -alh'”查看正在访问的文件并查看 mtime/ctime。但是,我想查看读取/写入这些文件的数据速率。 IE:我需要确定是否正在以 100 Mbps 的速度读取一个文件并耗尽磁盘空间。随后,是否有多个文件正在以 1 Mbps 的速度写入?查看特定磁盘的吞吐量并不太有用,因为我需要缩小正在处理的文件的范围。
恐怕还有一个问题;理想情况下,我需要在不安装任何其他软件或编写脚本的情况下确定这一点......仅仅是因为这是那些“非常生产”的系统之一。
有人知道有办法吗?非常感谢您的任何建议。
I have a custom application which has a bunch of files open. I can see the file handles open by a process using "lsof" and I can see the files being accessed using "watch -d 'ls -alh'" and watching the mtime/ctime. However, I would like to see the rate of data that is being read/written to these files. IE: I need to determine if one file is being read at 100 Mbps and maxing out a disk. Subsequently, are there several files which are being written at 1 Mbps? Looking at the throughput for a specific disk isn't too useful as I need to narrow down which file is being hammered.
I'm afraid there is also a catch; ideally I need to determine this without installing any other software or writing scripts... Simply because this is one of those "very-production" systems.
Does anybody know of a way? Many thanks in advance for any suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
strace
。它可以附加到正在运行的进程,并准确地告诉您它们执行的系统调用以及参数是什么 - 使用一个小的解释器脚本,您可以在观看时准确地推断出从哪个文件句柄读取了多少字节。Check out
strace
. It can attach to running processes and tell you exactly what syscalls they execute and what the parameters are - with a small interpreter script, you can deduce exactly how many bytes are being read from which file handle while you watch.