How to Install iostat on Ubuntu 22.04 | 20.04

Iostat is a popular system monitoring and performance analysis tool widely used on Linux systems. It provides detailed information on system resources such as CPU utilization, disk I/O, and network utilization, which can help system administrators monitor and optimize their systems’ performance.

Here are some of the key features and benefits of iostat:

  • Provides real-time system performance information: Iostat provides real-time information on system performance, allowing system administrators to monitor the performance of their systems and identify potential bottlenecks.
  • Detailed system resource information: Iostat provides detailed information on system resources such as CPU utilization, disk I/O, and network utilization, which can help administrators to identify which resources are being used the most and optimize their system accordingly.
  • Terminal-based interface: Iostat has a terminal-based interface, which can be used from the command line interface (CLI), making it easy to automate tasks and integrate them with other tools and scripts.
  • Customizable output format: Iostat allows you to customize the output format to suit your needs, making it easy to extract the information you need from the tool.

This guide will walk you through installing iostat on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa using the command line terminal. We’ll also provide some extra handy terminal command tips and configuration examples to help you get the most out of Iostat.

Update Ubuntu

To prevent any potential conflicts during the installation of Iostat, it is recommended to run a quick system apt update and upgrade before proceeding with the installation:

sudo apt update && sudo apt upgrade

Install iostat

Installing Iostat on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa is a breeze as it is included in the sysstat package by default. You can install it quickly by running the following command in your terminal:

sudo apt install sysstat

iostat Terminal Commands

The iostat command provides several options to obtain system performance information. Here’s a table that explains the available iostat command options:

OptionDescription
-cDisplay CPU utilization statistics.
-dDisplay disk I/O statistics.
-hDisplay help information.
-kDisplay statistics in kilobytes.
-mDisplay statistics in megabytes.
-NDisable display of NFS statistics.
-sDisplay disk utilization statistics.
-tInclude the time in the output.
-VDisplay the version information.
-xDisplay extended disk I/O statistics.
-yDisplay tty statistics.
-zDisplay IP network statistics.
-fSpecify a directory to read statistics.
+fAdd a directory to the list of directories to read statistics from.
-jDisplay statistics for a specific device by label, UUID, or path.
–decSet the number of decimal places to display.
–humanDisplay statistics in a human-readable format.
–prettyDisplay statistics in a pretty format.
-o JSONOutput the statistics in JSON format.
-HDisplay statistics for a specific disk group.
-gDisplay statistics for a specific device group.
-pDisplay statistics for specific devices or all devices.

You can use these options to customize the output of the iostat command to suit your needs and obtain detailed system performance information.

Here are five commonly used iostat terminal command examples:

Disk I/O Statistics:

This command displays detailed disk I/O statistics for all disks on the system.

iostat -d

The output displays the device name, transfers per second (tps), kilobytes read per second (kB_read/s), kilobytes written per second (kB_wrtn/s), total kilobytes read (kB_read), and total kilobytes written (kB_wrtn) for each disk on the system.

CPU Utilization Statistics:

This command displays CPU utilization statistics.

iostat -c

The output displays the percentage of CPU utilization by user-level processes, the percentage of CPU utilization by user-level processes with an excellent value greater than zero, the percentage of CPU utilization by system-level processes, the percentage of time that the CPU is idle during which the system is waiting for an I/O operation to complete, percentage of CPU utilization that is being taken from a virtual machine by the hypervisor, and percentage of time that the CPU is idle.

Disk I/O Statistics in Megabytes per Second:

This command displays disk I/O statistics in megabytes per second instead of kilobytes per second.

iostat -m

The output displays the device name, transfers per second (tps), megabytes read per second (MB_read/s), megabytes written per second (MB_wrtn/s), total megabytes read (MB_read), and total megabytes written (MB_wrtn) for each disk on the system.

Time Stamp for Each Line of Output:

This command displays the time stamp for each line of output.

iostat -t

The output displays the time stamp for each output line in the “MM/DD/YY HH:MM:SS” format.

Extended Disk I/O Statistics:

This command displays extended disk I/O statistics.

iostat -x

The output displays read requests merged per second (rrqm/s), write requests merged per second (wrqm/s), read requests per second (r/s), write requests per second (w/s), sectors read per second (rsec/s), sectors written per second (wsec/s), average request size in sectors (avgrq-sz), average queue length (avgqu-sz), the average time in queue (await), average service time (svctm), and percentage of time that the device is busy (%util) for each disk on the system.

Configuring iostat

To configure iostat, you can modify the configuration file located at /etc/sysstat/sysstat using the nano text editor.

sudo nano /etc/sysstat/sysstat

Here are a few commonly used methods or tips for configuring Iostat:

Changing the Update Interval:

To change the update interval for Iostat, open the /etc/default/sysstat file using the nano text editor and modify the value of the INTERVAL parameter. For example, to set the update interval to 10 seconds, change the line to:

INTERVAL="10"

Configuring Disk Monitoring:

To configure disk monitoring for Iostat, open the /etc/default/sysstat file and modify the value of the DISK parameter. For example, to monitor the sda and sdb disks, change the line to:

DISK="/dev/sda /dev/sdb"

Enabling Extended Statistics:

To enable extended statistics for Iostat, open the /etc/default/sysstat file and modify the value of the OPTIONS parameter. For example, to enable all extended statistics, change the line to:

OPTIONS="-d -p -t -u -x"

Setting the History Retention:

To set the history retention for Iostat, open the /etc/sysstat/sysstat file using the nano text editor and modify the value of the HISTORY parameter. For example, to retain one week of history, change the line to:

HISTORY="7"

Customizing the Output Format:

To customize the output format for Iostat, open the /etc/sysstat/sysstat file using the nano text editor and modify the value of the MPSTAT_OPTS and PIDSTAT_OPTS parameters. For example, to customize the output format for the mpstat command, change the line to:

MPSTAT_OPTS="-A -u -I ALL"

This will display all CPU utilization statistics and interrupt statistics in the output.

Similarly, to customize the output format for the pidstat command, change the line to:

PIDSTAT_OPTS="-u -r -H"

This will display CPU utilization, memory utilization, and thread-level statistics in the output.

Conclusion

In conclusion, installing iostat on Ubuntu 22.04 Jammy Jellyfish or Ubuntu 20.04 Focal Fossa is a quick and easy process that can be accomplished using the command line terminal. Iostat is a powerful tool that can help you monitor and optimize the performance of your system by providing detailed information on system resources such as CPU utilization, disk I/O, and network utilization.