1.释义
用于输出CPU和磁盘I/O相关的统计信息
2.系统帮助
用法: iostat [ 选项 ] [ <时间间隔> [ <次数> ] ] 选项: [ -c ] :显示CPU的I/O信息 [ -d ]:显示Device的I/O信息 [ -h ]:人性化显示 [ -k | -m ]:输出结果以kB/mB为单位显示 [ -N ]: [ -t ] [ -V ]:显示版本信息 [ -x ]:输出更详细的io设备统计信息 [ -y ]: [ -z ]: [ -j { ID | LABEL | PATH | UUID | ... } ] [ [ -T ] -g <用户组名> ] [ -p [ <设备> [,...] | ALL ] ] [ <设备> [...] | ALL ]
3.图示
avg-cpu
: 总体cpu使用情况统计信息,对于多核cpu,这里为所有cpu的平均值。重点关注iowait值,表示CPU用于等待io请求的完成时间。
%user
:表示用户占用的I/O比
%nice
: 表示运行低优先级进程占用的I/O比
%system
:表示内核占用的I/O比
%iowait
:表示剩余的I/O比
%steal
:表示当前系统运行在虚拟机中的时候占用的I/O比
%idle
:表示空闲I/O比
Device
: 设备名称
rrqm/s
: 每秒进行 merge 的读操作数目。即 delta(rmerge)/s
wrqm/s
:每秒进行 merge 的写操作数目。即 delta(wmerge)/s
r/s
:每秒完成的读 I/O 设备次数。即 delta(rio)/s
w/s
:每秒完成的写 I/O 设备次数。即 delta(wio)/s
rMB/s
:每秒读的兆数
wMB/s
:每秒写的兆数
avgrq-sz
:平均每次设备I/O操作的数据大小 (扇区)。delta(rsect+wsect)/delta(rio+wio)
avgqu-sz
:平均I/O队列长度。即 delta(aveq)/s/1000 (因为aveq的单位为毫秒)
await
:平均每次设备I/O操作的等待时间 (毫秒)。即 delta(ruse+wuse)/delta(rio+wio)
r_await
:读取等待时间
w_await
:写入等待时间
svctm
:平均每次设备I/O操作的服务时间 (毫秒)。即 delta(use)/delta(rio+wio)
%util
:一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的。即 delta(use)/s/1000 (因为use的单位为毫秒)
tps
: 每秒进程下发的IO读、写请求数量
KB_read/s
: 每秒从驱动器读入的数据量,单位为K。
KB_wrtn/s
: 每秒从驱动器写入的数据量,单位为K。
KB_read
: 读入数据总量,单位为K。
KB_wrtn
: 写入数据总量,单位为K。
%util
接近100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘可能存在瓶颈。%idle
值越小I/O压力就越大,%iowait
值越大说明I/O等待的时间就越长,同时可以结合vmstat
查看查看b
参数(等待资源的进程数)和wa参数(IO等待所占用的CPU时间的百分比,高过30%时IO压力高)4.示例
4.1.动态查看详细信息
[root@ansible-manager ~]#iostat -cmdx 10 Linux 3.10.0-957.el7.x86_64 (ansible-manager) 2020年05月31日 _x86_64_ (16 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.02 0.00 0.01 0.01 0.00 99.96 Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 0.01 0.09 0.52 0.00 0.02 63.42 0.04 73.12 7.01 84.89 6.08 0.37 dm-0 0.00 0.00 0.08 0.52 0.00 0.02 63.67 0.05 78.05 7.83 89.12 6.03 0.36 dm-1 0.00 0.00 0.00 0.00 0.00 0.00 16.57 0.00 33.00 4.29 44.26 7.85 0.00
4.2.只查看CPU
[root@ansible-manager ~]#iostat -c Linux 3.10.0-957.el7.x86_64 (ansible-manager) 2020年05月31日 _x86_64_ (16 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.02 0.00 0.01 0.01 0.00 99.96
4.3.只查看设备
[root@ansible-manager ~]#iostat -d Linux 3.10.0-957.el7.x86_64 (ansible-manager) 2020年05月31日 _x86_64_ (16 CPU) Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 0.61 2.53 16.84 475875 3170409 dm-0 0.60 2.36 16.75 443514 3153652 dm-1 0.00 0.01 0.01 2652 1408
4.4.以kB为单位显示
[root@ansible-manager ~]#iostat -k Linux 3.10.0-957.el7.x86_64 (ansible-manager) 2020年05月31日 _x86_64_ (16 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.02 0.00 0.01 0.01 0.00 99.96 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 0.61 2.53 16.87 475875 3177664 dm-0 0.60 2.35 16.78 443514 3160907 dm-1 0.00 0.01 0.01 2652 1408
4.5.以mB为单位显示
[root@ansible-manager ~]#iostat -m Linux 3.10.0-957.el7.x86_64 (ansible-manager) 2020年05月31日 _x86_64_ (16 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.02 0.00 0.01 0.01 0.00 99.96 Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn sda 0.61 0.00 0.02 464 3096 dm-0 0.60 0.00 0.02 433 3080 dm-1 0.00 0.00 0.00 2 1
4.6.动态输出
[root@ansible-manager ~]#iostat 5 Linux 3.10.0-957.el7.x86_64 (ansible-manager) 2020年05月31日 _x86_64_ (16 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.02 0.00 0.01 0.01 0.00 99.96 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 0.62 2.53 16.88 475875 3179602 dm-0 0.60 2.35 16.79 443514 3162845 dm-1 0.00 0.01 0.01 2652 1408