命令

dstat

查看 CPU 和 I/O 这两种资源
[root@Linkin high-iowait-process]# dstat 1 10
You did not select any stats, using -cdngy by default.
——total-cpu-usage—— -dsk/total- -net/total- —-paging— —-system—
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
9 4 84 2 0 0| 444B 3538k| 0 0 | 0 0 | 477 8109
1 0 99 0 0 0| 0 0 | 132B 158B| 0 0 | 619 1159
0 0 100 0 0 0| 0 0 | 66B 102B| 0 0 | 564 1095
1 0 100 0 0 0| 0 0 | 108B 1180B| 0 0 | 484 999
0 0 100 0 0 0| 0 0 | 66B 350B| 0 0 | 485 1011
0 0 99 0 0 0| 0 0 | 66B 350B| 0 0 | 529 1053
0 0 100 0 0 0| 0 96k| 66B 350B| 0 0 | 577 1117
0 1 100 0 0 0| 0 0 | 66B 350B| 0 0 | 591 1130
1 0 100 0 0 0| 0 0 | 66B 358B| 0 0 | 577 1108
0 0 100 0 0 0| 0 0 | 66B 42B| 0 0 | 525 1058
0 1 99 0 0 0| 0 40k| 66B 350B| 0 0 | 615 1225
[root@Linkin high-iowait-process]# pidstat -d -p 3827 1 3
Linux 3.10.0-1062.9.1.el7.x8664 (Linkin) 05/30/2020 _x86_64 (2 CPU)

01:38:31 PM UID PID kB_rd/s kB_wr/s kB_ccwr/s Command
01:38:32 PM 994 3827 0.00 0.00 0.00 influxd
01:38:33 PM 994 3827 0.00 0.00 0.00 influxd
01:38:34 PM 994 3827 0.00 0.00 0.00 influxd
Average: 994 3827 0.00 0.00 0.00 influxd
iowait 高不一定代表 I/O 有性能瓶颈。当系统中只有 I/O 类型的进程在运行时,iowait 也会很高,但实际上,磁盘的读写远没有达到性能瓶颈的程度

总结

跟踪进程系统调用

strace

使用 -d 参数来展示 I/O 的数据

pidstat