Mar 26, 2024 6 min read

How to Install iostat on Ubuntu 22.04

Install iostat on Ubuntu 22.04 with our step-by-step tutorial. Iostat is a tool to monitor and analyze system I/O statistics on Linux systems.

Install iostat on Ubuntu 22.04
Install iostat on Ubuntu 22.04
Table of Contents

Introduction

Before we begin talking about how to install iostat on Ubuntu 22.04, let's briefly understand – What is iostat?

The iostat is a powerful tool used for monitoring and analyzing system input/output (I/O) statistics on Linux-based operating systems. It provides valuable insights into disk, CPU, and device utilization, helping administrators identify performance bottlenecks. With iostat, you can gain a comprehensive understanding of how your system resources are being utilized, allowing you to optimize your system for enhanced efficiency and better performance.

In this tutorial, you will install iostat on Ubuntu 22.04. We will also address a few FAQs on how to install iostat on Ubuntu 22.04.

Advantages of iostat

  1. Performance Monitoring: Iostat allows real-time monitoring of disk, CPU, and device utilization, helping identify performance bottlenecks.
  2. Resource Optimization: By analyzing I/O statistics, iostat helps optimize system resources for enhanced efficiency and better overall performance.
  3. Diagnostic Insights: It provides valuable insights into disk operations, identifying issues like high disk utilization and excessive response times.
  4. Historical Data Analysis: Iostat can generate historical reports, allowing administrators to analyze trends and patterns for long-term performance evaluation.
  5. Customizable Output: Administrators can choose the specific metrics and format of output, tailoring it to their specific monitoring needs.

Update Ubuntu

Before beginning the installation of Iostat, it is advised to perform a quick system apt update and upgrade in order to avoid any potential conflicts:

sudo apt update && sudo apt upgrade

Install iostat

Since Iostat is pre-installed in the sysstat package, installing it on Ubuntu 20.04 Focal Fossa or Ubuntu 22.04 Jammy Jellyfish is simple. By entering the following command into your terminal, you can install it quickly:

sudo apt install sysstat

iostat Terminal Commands

There are multiple ways to get system performance data with the iostat command. The available iostat command options are explained in the following table:

  • -c: Display CPU utilization statistics.
  • -d: Display disk I/O statistics.
  • -h: Display help information.
  • -k: Display statistics in kilobytes.
  • -m: Display statistics in megabytes.
  • -N: Disable display of NFS statistics.
  • -s: Display disk utilization statistics.
  • -t: Include the time in the output.
  • -V: Display the version information.
  • -x: Display extended disk I/O statistics.
  • -y: Display tty statistics.
  • -z: Display IP network statistics.
  • -f: Specify a directory to read statistics.
  • +f: Read statistics, add a directory to the list of directories.
  • -j: Display statistics for a specific device by label, UUID, or path.
  • –dec: Decimal places to display can be set.
  • –human: Display statistics in a human-readable format.
  • –pretty: Display statistics in a pretty format.
  • -o JSON: Output the statistics in JSON format.
  • -H: Display statistics for a specific disk group.
  • -g: Display statistics for a specific device group.
  • -p: Display device-specific or device-wide statistics.

By customizing the iostat command's output to your specifications, you can get comprehensive information about the system's performance.

Here are five typical examples of iostat terminal commands that are used:

Disk I/O Statistics:

This command shows all the system's disks' detailed I/O statistics.

iostat -d

For every disk in the system, the output shows the name of the device, 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).

CPU Utilization Statistics:

Statistics about CPU utilization are shown by this command.

iostat -c

The percentage of CPU utilization by system-level processes, user-level processes, processes with an excellent value greater than zero, the percentage of CPU utilization by user-level processes, the percentage of CPU idle time while the system waits for an I/O operation to finish, the percentage of CPU utilization that the hypervisor is taking from a virtual machine, and the percentage of idle time are all displayed in the output.

Disk I/O Statistics in Megabytes per Second:

Rather than using kilobytes per second, this command shows disk I/O statistics in megabytes per second.

iostat -m

For every disk in the system, the output shows the name of the device, 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).

Time Stamp for Each Line of Output:

The time stamp for each line of output is shown by this command.

iostat -t

Every output line's time stamp is shown in the output in the format "MM/DD/YY HH:MM:SS."

Extended Disk I/O Statistics:

The extended disk I/O statistics are shown by this command.

iostat -x

The output shows 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

Using the nano text editor, you can edit the configuration file at /etc/sysstat/sysstat to configure iostat.

sudo nano /etc/sysstat/sysstat

Here are some frequently used techniques or configuration advice for Iostat:

Changing the Update Interval:

Using the nano text editor, open the /etc/default/sysstat file and edit the value of the INTERVAL parameter to adjust the Iostat update interval. For instance, alter the line to: in order to set the update interval to 10 seconds.

INTERVAL="10"

Configuring Disk Monitoring:

Open the /etc/default/sysstat file and change the value of the DISK parameter to configure disk monitoring for Iostat. For instance, alter the line to: in order to monitor the sda and sdb disks.

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

Enabling Extended Statistics:

Open the /etc/default/sysstat file and change the value of the OPTIONS parameter to enable extended statistics for Iostat. For instance, alter the line to: in order to enable all extended statistics.

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

Setting the History Retention:

Using the nano text editor, open the /etc/sysstat/sysstat file and change the value of the HISTORY parameter to set the history retention for Iostat. For instance, alter the line to: in order to save one week's worth of history.

HISTORY="7"

Customizing the Output Format:

Using the nano text editor, open the /etc/sysstat/sysstat file and change the MPSTAT_OPTS and PIDSTAT_OPTS parameters to alter the iostat output format. For instance, alter the line to: to alter the mpstat command's output format:

MPSTAT_OPTS="-A -u -I ALL"

The output will show all statistics related to CPU utilization and interrupts.

Likewise, modify the line to: to alter the pidstat command's output format:

PIDSTAT_OPTS="-u -r -H"

The output will show thread-level statistics, CPU utilization, and memory utilization.

FAQs to Install iostat on Ubuntu 22.04

What is sysstat, and why is it needed for iostat on Ubuntu?

Sysstat is a package that provides a collection of performance monitoring tools for Linux systems. It includes iostat, which is a tool used to monitor I/O statistics. You need to install sysstat to use iostat.

Can I use iostat on Ubuntu 22.04 without installing sysstat? 

No, iostat is part of the sysstat package. To use iostat, you will need to install sysstat on your Ubuntu 22.04 system.

How do I run iostat on Ubuntu 22.04? 

To run iostat on Ubuntu 22.04, you can open the terminal and execute the command for iostat, along with any desired options or parameters.

What are the most useful options for running iostat on Ubuntu? 

Some useful options for running iostat on Ubuntu include display options like disk-related statistics (-d), CPU-related statistics (-c), or extended statistics (-x).

Can iostat display real-time statistics on Ubuntu? 

Yes, iostat can display real-time statistics by using appropriate options or parameters. This allows you to monitor system performance as it happens.

Where can I find iostat reports on Ubuntu 22.04? 

By default, iostat does not save reports. However, you can redirect the output of iostat to a file if you want to generate and save reports for further analysis.

How can I interpret the output of iostat on Ubuntu? 

The output of iostat provides information about disk utilization, CPU usage, and I/O wait times. Higher values in these metrics may indicate performance issues.

Conclusion

We hope this tutorial helped you understand how to install iostat on Ubuntu 22.04.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.