03-查看磁盘I/O使用状况:iotop

Posted hejianping

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了03-查看磁盘I/O使用状况:iotop相关的知识,希望对你有一定的参考价值。

iotop是一个用来监视磁盘I/O使用状况的 top 类工具,可监测到哪一个程序使用的磁盘IO的信息,磁盘io异常时可以用来排查问题。

直接输入iotop时输出,可以看到系统磁盘io负载不高:

Total DISK READ: 0.00 B/s | Total DISK WRITE: 393.90 K/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
1143 be/3 root 0.00 B/s 30.59 K/s 0.00 % 5.14 % [jbd2/sda3-8]
12122 be/4 root 0.00 B/s 11.47 K/s 0.00 % 0.00 % syslog-ng -p /var/run/syslog-ng.pid
2048 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % sh -c echo "[`date +"%F %T"`] `/usr/~ /tmp/crontab_uploadSourceAsBs2.log &
1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init
2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd]
3 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0]
6 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0]
7 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/0]
8 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/1]
10 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/1]
26635 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % ./devops_channel_d --c channel.conf --d disable
12 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/1]
13 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/2]
14 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kworker/2:0]
15 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/2]
16 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/2]
17 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/3]
19 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/3]
20 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/3]
21 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/4]
2070 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % php /data/webapps/sy.admin.duowan.co~tected/bin/game/uploadSourceAsBs2.php
23 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/4]
24 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/4]
25 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/5]
27 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/5]
28 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/5]
29 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/6]
31 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/6]
32 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/6]
33 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/7]
35 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/7]
[email protected]:~$ 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/7]

常用参数:

-n:显示输出次数
-o:只显示有io输出的进程
-b:阻止动态显示

最常用使用的组合:

iotop -bon5
[email protected]:~$ sudo iotop -bon5
Total DISK READ:       0.00 B/s | Total DISK WRITE:       0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
 5373 be/4 root        0.00 B/s   70.52 K/s  0.00 %  0.00 % bash /data/services/rsync-3.0.7.4/admin/report.sh
Total DISK READ:       0.00 B/s | Total DISK WRITE:     287.33 K/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
16716 be/4 root        0.00 B/s    3.83 K/s  0.00 %  0.00 % ./yyms_agent_d
12122 be/4 root        0.00 B/s    7.66 K/s  0.00 %  0.00 % syslog-ng -p /var/run/syslog-ng.pid
Total DISK READ:       0.00 B/s | Total DISK WRITE:       0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
23842 be/4 www-data    0.00 B/s    3.83 K/s  0.00 %  0.00 % nginx: worker process
Total DISK READ:     122.51 K/s | Total DISK WRITE:     520.68 K/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
 1143 be/3 root        0.00 B/s  248.86 K/s  0.00 %  4.11 % [jbd2/sda3-8]
  497 be/3 root        0.00 B/s  126.34 K/s  0.00 %  3.42 % [jbd2/sda1-8]
23842 be/4 www-data    0.00 B/s    7.66 K/s  0.00 %  0.00 % nginx: worker process
23848 be/4 www-data  122.51 K/s    0.00 B/s  0.00 %  0.00 % nginx: worker process
Total DISK READ:       0.00 B/s | Total DISK WRITE:       0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN      IO    COMMAND
19119 be/4 root        0.00 B/s    3.83 K/s  0.00 %  0.00 % ./yyms_agent_d
  843 be/4 root        0.00 B/s    7.65 K/s  0.00 %  0.00 % ./yyms_agent_d
23836 be/4 www-data    0.00 B/s    3.83 K/s  0.00 %  0.00 % nginx: worker process
[email protected]:~$ 

可以看出,该服务器上面并没有占用磁盘io较高的业务。

 

以上是关于03-查看磁盘I/O使用状况:iotop的主要内容,如果未能解决你的问题,请参考以下文章

iotop命令

Linux下使用iotop检测磁盘io使用情况

七周二次课

iotop命令

iotop命令

Iotop—Linux上监控磁盘I/O的利器详细使用说明