This is the 19th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021

Introduction of the command

Iostat stands for I/O statistics. The iostat command is used to monitor disk operations in the system. , including read and write times, data volume, SERVICE time and waiting time of I/O requests. The iostat command can also be used to check CPU utilization and NFS network file system processing activities.

The first report generated by the iostat command is the average statistics from system startup to date. Each subsequent report is a collection of statistics from the previous report until the specified interval. Statistics reports typically include a CPU header line, along with CPU utilization statistics. In a multi-CPU system, CPU statistics are the average of all CPU processing activities. In addition, the statistics report also includes a device title line and statistics for each I/O device. When the -n option is specified, iostat displays only the NFS header line and statistics for each installed NFS file system.

Iostat also has a weakness in that it does not provide in-depth analysis of a process, only of the system as a whole.

The command format

Iostat [parameter][time][number of times]Copy the code

The command parameter

parameter explain
-c Displays categorized statistics on CPU usage.
-d Displays classified statistics on device usage.
-h Display in legible, appropriate units-nOption to provide NFS statistics.
-k Display statistics in kilobytes per second (rather than the default data blocks per second).
-m Displays statistics in MB/s.
-n Displays NFS statistics.
-N Use to display LVM2 volume statistics.
`-p[devices ALL]`
-t Adds time information to the displayed statistics (the display format of time depends on the setting of the S_TIME_FORMAT environment variable).
-V Display the version and copyright information of the command and exit.
-x Displays additional statistics.
-z Disallow any device that does not have I/O activity during data sampling.

The output data

The iostat command can generate three types of statistics: CPU usage, I/O device usage, and NFS network file system.

CPU usage (in a multi-CPU system, statistics are the average of all cpus)

field explain
%user User mode elapsed time (application) percentage of total CPU time.
%nice The percentage of total CPU time spent in user mode running time (processing processes with priority adjustment values).
%system Kernel mode elapsed time (system) as a percentage of total CPU time.
%iowait The percentage of total CPU time spent idle while waiting for I/O to complete.
%steal Percentage of total CPU time spent waiting for services to be provided by the virtual machine manager.
%idle The percentage of total CPU time consumed when the CPU is completely idle (with no I/O requests waiting to be processed).

Storage Device Usage (Statistics by storage device or partition)

If you want to view a specific block device and display statistics, you can specify the device name of the block device or partition on the command line. If neither block device file name nor partition device file name is specified, statistics for each storage device used by the system are displayed separately. If the keyword ALL is specified, the statistics of each device (including unused devices) maintained by the system are displayed. Depending on the command line options, the output report will typically contain the following fields.

field explain
Device The name of the device or partition (standard device filename/dev/nameomit/devSection)
tps The actual number of data I/O performed by the device per second (multiple logical I/O requests can be combined into one actual I/O request).
Blk_read/s The number of data blocks read from the device per second.
Blk_wrtn/s The number of data blocks written to the device per second.
Blk_read The total amount of data blocks read from the device.
Blk_wrtn The total number of data blocks written to the device.
kB_read/s Amount of data read from the device per second (KB).
kB_wrtn/s Data volume written to the device per second (KB).
kB_read Total data read from the device (KB).
kB_wrtn Total data written to the device (KB).
MB_read/s Data read from the device per second (MB).
MB_wrtn/s Data volume written to the device per second (MB).
MB_read Total data read from the device (MB).
MB_wrtn Total data written to the device (MB).
rrqm/s Number of merge request reads per second.
wrqm/s Number of merge requests to write devices per second.
r/s Number of read requests processed by the device per second.
w/s Number of write requests processed by the device per second.
rsec/s The number of sectors read from the device per second.
wsec/s The number of sectors written to the device per second.
rkB/s Amount of data read from the device per second (KB).
wkB/s Data volume written to the device per second (KB).
rMB/s Data read from the device per second (MB).
wMB/s Data volume written to the device per second (MB).
avgrq-sz Average number of sectors that the device receives read and write requests.
avgqu-sz Average queue length of read and write requests processed by the device.
await Average waiting time (ms) for the device to process I/O requests, including queue waiting time and actual service time.
svctm Average service time (milliseconds) for the device to process I/O requests.
%util Percentage of total CPU time spent by a device processing I/O requests. If this number is close to 100%, the device is about to reach saturation.

NFS network file systems (categorized statistics for each network file system installed)

field explain
Filesystem The host name of the NFS server and the name of the shared directory resource, such as host:/directory.
rBlk_nor/s The number of data blocks read by the read(2) system call applied.
wBlk_nor/s The number of data blocks written by the application through write(2) system calls.
rBlk_dir/s The number of data blocks read from a file with the open flag O_DIRECT.
wBlk_dir/s Number of data blocks written to a file with open flag O_DIRECT.
rBlk_svr/s The number of data blocks that an NFS client requests to READ from the NFS server through NFS READ.
wBlk_svr/s Number of data blocks that NFS clients request to WRITE to the NFS server through NFS WRITE.
rkB_nor/s The amount of data (KB) read by the application through the read(2) system call.
wkB_nor/s The amount of data written by the application through write(2) system call (KB).
rkB_dir/s The amount of data (KB) read from a file marked O_DIRECT.
wkB_dir/s The amount of data (KB) written to the file with the open flag O_DIRECT.
rkB_svr/s The amount of data (KB) that an NFS client reads from the NFS server through NFS READ requests.
wkB_svr/s The amount of data requested by NFS clients to WRITE to the NFS server through NFS WRITE (KB).
rMB_nor/s The amount of data (MB) read by the application through the read(2) system call.
wMB_nor/s The amount of data read by the application through write(2) system call (MB).
rMB_dir/s The amount of data (MB) read from a file marked O_DIRECT.
wMB_dir/s Amount of data (MB) written to a file with open flag O_DIRECT.
rMB_svr/s The amount of data (MB) that an NFS client reads from the NFS server through NFS READ requests.
wMB_svr/s The amount of data requested by NFS clients to WRITE to the NFS server through NFS WRITE (KB).
ops/s Number of read and write operations processed by the NFS server file system per second.
rops/s Number of read operations processed by the NFS server file system per second.
wops/s Number of write operations processed by the NFS server file system per second.

Examples of application

  1. Displays the load of all devices
iostat
Copy the code
  1. Display all information periodically
iostat 2 3
Copy the code

Reference documentation

  • Iostat command
  • “Linux Common Commands concise Manual” — Xing Guoqing edited