iostat Command in Linux - Explained with examples

The iostat command in Linux allows users to monitor system i/o statistics on the device. It is based on how long the devices are operating at the average baud rate to monitor the input/output of the system. Based on reports, system configurations can be changed to optimize CPU performance. This command is in the sysstat package.

Here at LinuxAPT, we shall look into how to use the iostat command in Linux.

Iostat Installation on Linux Systems:

iostat is a part of 'sysstat' package, we can install it on our system using the following command.

In CentOS/RedHat:

# yum install sysstat -y

On Ubuntu/Debian:

$ sudo apt-get install sysstat -y

On Fedora:

# dnf install sysstat -y

How to use iostat command ?

To display monitoring reports, run the below command:

$ iostat

In the output, you will see the CPU report and Device report.

iostat command Parameter:

1. CPU:

  • %user: % CPU usage
  • %nice: % CPU usage with nice priority
  • % system: % CPU usage at the system level
  • %iowait: % of CPU time idle and system request i/o
  • %steal: % virtual CPU waiting while another virtual processor is serving the hypervisor
  • %idle: % CPU time idle and no system request i/o

2. Device:

  • Device: the I/O device name
  • tps: the transfers per second
  • kB_read/s: the amount of data CPU read per second in kiloBytes (kB)
  • kB_wrtn/s: the amount of data CPU written per second in kiloBytes (kB)
  • kB_dscd/s: the rate of data CPU discarded per second in kiloBytes (kB)
  • kB_read: the total number of blocks read
  • kB_wrtn: the total number of blocks written
  • kB_dscd: the total number of blocks discarded

What is the syntax of the iostat command ?

It is given below:

$ iostat [option] [device-name]

iostat command option:

1. -c: displaying summary of monitoring reports:

$ iostat -c

2. -d: displaying I/O devices report only:

$ iostat -d

3. -x: displaying the detailed report:

$ iostat -x

4. -m: displaying reports in MegaBytes:

$ iostat -m

5. -k: displaying reports in kiloBytes:

$ iostat -k

6. -p: displaying device block report:

$ iostat -p

[Need help in fixing Linux system issues ? We can help you. ]

This article covers how to use the iostat command in Linux. In fact, iostat command is used to monitor CPU utilization and I/O (input /output) statistics of all the disks and file systems. nfsiostat command is used to monitor i/o statistics of network file system(NFS).

iostat command generally generates two reports:

  • CPU utilization report.
  • All disks i/o statistics report.

To generate the reports, iostat command reads some of the system files . These files are:

  • /proc/diskstats for disk stats.
  • /proc/stat for system stats.
  • /sys for block device stats.
  • /proc/devices for persistent device names.
  • /proc/self/mountstats for all  the network filesystems.
  • /proc/uptime for information regarding system uptime.

Related Posts