iostat – Monitors system I/O device and CPU usage

The iostat command is used to monitor system input/output (I/O) device and central processing unit (CPU) usage. It provides detailed statistics about the CPU, hard drives, and other input/output devices. This information can be used to identify performance bottlenecks and tune the system for optimal performance.

Overview

The iostat command is used to monitor system I/O device and CPU usage. It can be used to display statistics in real-time or to generate reports for a specified time period. The syntax for the iostat command is as follows:

iostat [options] [interval] [count]

Here, options are the various options available for the command, interval is the time interval (in seconds) between each report, and count is the number of reports to generate.

Examples

To display CPU statistics in real-time, use the following command:

iostat 1

This will display CPU statistics every second.

To display disk statistics for a specified time period, use the following command:

iostat -d 5 10

This will display disk statistics every 5 seconds for a total of 10 reports.

Use cases

The iostat command can be used to monitor system performance and identify performance bottlenecks. It can be used to:

  • Monitor CPU usage
  • Monitor disk usage
  • Identify disk I/O bottlenecks
  • Monitor network usage

Options

The following options are available for the iostat command:

Option Description
-c Display only CPU statistics
-d Display only disk statistics
-k Display statistics in kilobytes per second
-m Display statistics in megabytes per second
-N Display network statistics
-t Include timestamp with each report
-x Display extended disk statistics

Troubleshooting tips

  • If the iostat command is not installed on your system, you can install it using your system’s package manager. For example, on Ubuntu, you can use the following command: sudo apt-get install sysstat
  • If you are not seeing any output from the iostat command, try specifying a longer interval or a higher count.

Notes

  • The iostat command is part of the sysstat package.
  • The iostat command requires root privileges to run.
  • The iostat command is available on most Linux distributions.