每个PID的硬盘I / O


9

有什么方法可以查看每个pid /进程的磁盘I / O吗?Monitorix向我显示以下内容,如果我错了,请纠正我,但是看来硬盘驱动器正在减慢整个系统的速度: 在此处输入图片说明

更新1

Atop似乎对所有内容都给出了很好的概述。

  • 我可能会问你,我标记为红色的等待意味着什么?
  • 那是来自磁盘I / O的等待吗?

在此处输入图片说明


2
您拥有atop,iotop或pidstat
sebelk 2014年

1
@sebelk嘿,我更新了问题,如果您可以看一下,那将很好。:)
user2693017 2014年

1
选择一个最佳答案是不可能的,所以我决定选择一个对我帮助最大的答案,并否决了其他答案。
user2693017 2014年

@ user2693017-很好,因为OP是最适合您需求的特权。
slm

Answers:


3

我很难看清楚这些图片,但是:

在上面看看男人:

我想知道您是否最终会要求另一件事,在“ CPU”部分中您有:

Every  line contains the percentage of cpu time spent in kernel mode by all
active processes (`sys'), the percentage of cpu time consumed in user mode
(`user') for all active processes (including processes running with a nice
value larger than zero), the  percentage  of  cpu  time spent  for  interrupt
handling  (`irq')  including  softirq, the percentage of unused cpu time while
no processes were waiting for disk-I/O (`idle'), and the percentage of unused
cpu time while at least one process was waiting for disk-I/O (`wait').

In case of per-cpu occupation, the last column shows the cpu number and the
wait percentage (`w') for that cpu.  The number of lines showing the per-cpu
occupation can be limited.

无论如何,您都可以阅读磁盘特定的统计信息:

d    Show disk-related output.

            When "storage accounting" is active in  the  kernel,  the  
            following  fields  are shown: process-id, amount of data read 
            from disk, amount of data written to disk, amount of data that 
            was written but has been withdrawn again (WCANCL), disk 
            occupation percentage and process name.

以及这些选项。

d

    D   Sort  the  current  list  in the order of disk accesses issued.  
        The one-but-last column changes to ``DSK''.
        ...

RDDSK

RDDSK   When the kernel maintains standard io statistics (>= 2.6.20):

        The  read  data  transfer issued physically on disk (so reading from 
        the disk cache is not accounted for).
        ...

WRDSK

WRDSK   When the kernel maintains standard io statistics (>= 2.6.20):

        The  write  data  transfer  issued physically on disk (so writing to 
        the disk cache is not accounted for).  This counter is maintained 
        for the  application process  that writes its data to the cache 
        (assuming that this data is physically transferred to disk later 
        on). Notice that disk I/O needed for swapping is not taken into 
        account.
        ....

LVM / MDD / DSK

LVM/MDD/DSK
        Logical volume/multiple device/disk utilization. 

        Per active unit one line is produced, sorted on unit activity.
        Such  line shows the name (e.g. VolGroup00-lvtmp for a logical
        volume or sda for a hard disk), the busy percentage i.e. the
        portion of time that the unit was busy handling requests
        (`busy'),  the  number  of  read  requests  issued  (`read'), the
        number of write requests issued (`write'), the number of KiBytes
        per read (`KiB/r'),  the  number of  KiBytes  per write
        (`KiB/w'), the number of MiBytes per second throughput for reads
        (`MBr/s'),  the  number  of  MiBytes  per second  throughput  for
        writes (`MBw/s'), the average queue depth (`avq') and the average
        number of milliseconds needed by a request (`avio') for seek,
        latency and data transfer.

        If the screen-width does not allow all of these counters, only a
        relevant subset is shown.

        The  number of lines showing the units can be limited per class
        (LVM, MDD or DSK) with the 'l' key or statically (see separate
        man-page of atoprc).  By specifying the  value  0  for  a
        particular class, no lines will be shown any more for that class.

非常感谢。如果由于大小而困难,请直接链接:i.stack.imgur.com/5ifJi.png
user2693017 2014年

8

我相信有很多工具。其中之一是pidstat

pidstat -d 5

每5秒显示一次进程的I / O。

$ pidstat -d 5
Linux 3.12.11-201.fc19.x86_64 (greeneggs.bubba.net)     03/04/2014  _x86_64_    (4 CPU)

06:19:05 PM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
06:19:10 PM  1000     29486      0.00    317.93      0.00  chrome

06:19:10 PM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
06:19:15 PM  1000     29486      0.00    368.00      0.00  chrome

06:19:15 PM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
06:19:20 PM  1000     29486      0.00    591.62    836.73  chrome

06:19:20 PM   UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
06:19:25 PM  1000      2410      0.00      0.80      0.00  mono
06:19:25 PM  1000     29486      0.00    262.40      0.00  chrome
^C

Average:      UID       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
Average:     1000      2410      0.00      0.20      0.00  mono
Average:     1000     29486      0.00    385.02    209.29  chrome

从您看到Ctrl+ 的点开始,C^C上述运行期间的总和。


很好,是否可以让它运行1小时并获得整体结果?
user2693017 2014年

也许,我还没有尝试过。您也可以定义要检查的PID。

3

让我们看一下标题为:Amazon EC2微型实例大量IO请求的 U&L问答,在此我提供了有关名为的工具的详细信息fatrace。我还将在标题为“ 确定对高I / O负责的特定文件 ”的问答中对此进行介绍

宽容

这是Linux内核的新增功能,也是受人欢迎的功能,因此仅在较新的发行版中(例如Ubuntu 12.10)。我的Fedora 14系统缺少它8-)。

它提供了与inotify相同的访问权限,而不必针对特定的目录和/或文件。

$ sudo fatrace
pickup(4910): O /var/spool/postfix/maildrop
pickup(4910): C /var/spool/postfix/maildrop
sshd(4927): CO /etc/group
sshd(4927): CO /etc/passwd
sshd(4927): RCO /var/log/lastlog
sshd(4927): CWO /var/log/wtmp
sshd(4927): CWO /var/log/lastlog
sshd(6808): RO /bin/dash
sshd(6808): RO /lib/x86_64-linux-gnu/ld-2.15.so
sh(6808): R /lib/x86_64-linux-gnu/ld-2.15.so
sh(6808): O /etc/ld.so.cache
sh(6808): O /lib/x86_64-linux-gnu/libc-2.15.so

上面显示了正在执行文件访问的进程ID和正在访问的文件,但是它并没有为您提供整体带宽使用情况,因此每次访问都与其他访问没有区别。

注意: fatrace可以接受一个-p PID参数,因此可以根据需要将其定向为监视单个PID。


真的很好用的工具,谢谢,我不知道!
sebelk 2014年

您有一个相关且不错的工具ftop
sebelk

@sebelk-是的,谢谢,也已经安装了它。
slm

我喜欢这个工具。它显示了哪个任务访问磁盘上的哪些文件。但是,也可以映射这些文件,因此仅发生缓冲区访问,而没有IO访问。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.