Understanding iostat Options and Metrics on CentOS 8
Package Identification
The iostat utility is part of the sysstat package:
[root@centos8 ~]# whereis iostat
iostat: /usr/bin/iostat /usr/share/man/man1/iostat.1.gz
[root@centos8 ~]# rpm -qf /usr/bin/iostat
sysstat-11.7.3-2.el8.x86_64
If not found, install it using:
[root@blog ~]# yum install sysstat
Version and Help Information
Check version:
[root@centos8 ~]# iostat -V
sysstat version 11.7.3
Access manual:
[root@centos8 ~]# man iostat
Purpose
iostat is a key tool for monitoring disk I/O performance, presenting metrics like utilization, IOPS, throughput, and more from /proc/diskstats.
Command Syntax
Usage: iostat [options] [interval [count]]
Options
-c: Display only CPU statistics-d: Show only device statistics-x: Show extended statistics
Example 1: Full Disk I/O Metrics
Output every second with extended data:
[root@centos8 ~]# iostat -x -d 1
Linux 4.18.0-147.5.1.el8_1.x86_64 (centos8) 2020年04月03日 _x86_64_ (2 CPU)
Device r/s w/s rkB/s wkB/s rrqm/s wrqm/s %rrqm %wrqm r_await w_await aqu-sz rareq-sz wareq-sz svctm %util
sda 1.14 3.37 85.32 1752.17 0.01 0.14 0.61 3.87 1.38 9.60 0.03 74.76 519.91 0.64 0.29
scd0 0.00 0.00 0.07 0.00 0.00 0.00 0.00 0.00 1.16 0.00 0.00 28.65 0.00 1.14 0.00
dm-0 0.98 2.22 75.38 1717.20 0.00 0.00 0.00 0.00 1.29 16.56 0.04 76.61 774.24 0.58 0.18
...
Field Explanatiosn
Device: Device namer/s: Reads per secondw/s: Writes per secondrkB/s: Kilobytes read per secondwkB/s: Kilobytes written per secondrrqm/s: Read merges per secondwrqm/s: Write merges per second%rrqm: Percentage of read requests merged%wrqm: Percentage of write requests mergedr_await: Average read request wait time (ms)w_await: Average write request wait time (ms)aqu-sz: Average queue sizerareq-sz: Average read request sizewareq-sz: Average write request sizesvctm: Service time for I/O requests%util: Percentage of time the device is busy
In production, high %util indicates I/O saturation. High aqu-sz implies longer response times.
Example 2: CPU Statistics Only
[root@centos8 ~]# iostat -c 1 10
Linux 4.18.0-147.5.1.el8_1.x86_64 (centos8) 2020年04月03日 _x86_64_ (2 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
4.54 0.02 1.32 0.35 0.00 93.76
CPU Fields
%user: Time spent in user mode%nice: Time spent with nice priority%system: Time spent in system mode%iowait: Time waiting for I/O operations%steal: Time stolen by hypervisor%idle: Idle CPU time
Example 3: Basic Disk I/O
[root@centos8 ~]# iostat -d
Linux 4.18.0-147.5.1.el8_1.x86_64 (centos8) 2020年04月03日 _x86_64_ (2 CPU)
Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 3.88 73.07 1500.72 1348131 27687825
scd0 0.00 0.06 0.00 1060 0
...
Output Fields
tps: Transfers per secondkB_read/s: Kilobytes read per secondkB_wrtn/s: Kilobytes written per secondkB_read: Total kilobytes readkB_wrtn: Total kilobytes written
Difference Between -d and -d -x
iostat -d 1 10: Displays TPS and throughputiostat -d -x 1 10: Shows utilization (%util) and respnose times (await)
Logical Volumes (dm-* Devices)
These devices are LVM logical volumes:
[root@centos8 mapper]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 120G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 79G 0 part
├─cl-root 253:0 0 50G 0 lvm /
├─cl-swap 253:1 0 4G 0 lvm [SWAP]
└─cl-home 253:2 0 25G 0 lvm /home
[root@centos8 mapper]# ll /dev/mapper/
total 0
lrwxrwxrwx 1 root root 7 4月 3 12:48 cl-home -> ../dm-2
lrwxrwxrwx 1 root root 7 4月 3 12:48 cl-root -> ../dm-0
lrwxrwxrwx 1 root root 7 4月 3 12:48 cl-swap -> ../dm-1
OS Version Check
[root@centos8 ~]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)