Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Understanding iostat Options and Metrics on CentOS 8

Tech May 19 1

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 name
  • r/s: Reads per second
  • w/s: Writes per second
  • rkB/s: Kilobytes read per second
  • wkB/s: Kilobytes written per second
  • rrqm/s: Read merges per second
  • wrqm/s: Write merges per second
  • %rrqm: Percentage of read requests merged
  • %wrqm: Percentage of write requests merged
  • r_await: Average read request wait time (ms)
  • w_await: Average write request wait time (ms)
  • aqu-sz: Average queue size
  • rareq-sz: Average read request size
  • wareq-sz: Average write request size
  • svctm: 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 second
  • kB_read/s: Kilobytes read per second
  • kB_wrtn/s: Kilobytes written per second
  • kB_read: Total kilobytes read
  • kB_wrtn: Total kilobytes written

Difference Between -d and -d -x

  • iostat -d 1 10: Displays TPS and throughput
  • iostat -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)

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.