How to install and use iostat on Linux

IOSTAT, lightweight I / O statistics, is a popular system monitoring tool in Linux that allows users to identify various performance issues as well as retrieve CPU and system information from the statistics collection system it collects. These statistics, as the name IOSTAT suggests, includes the operating system for storing input and output data. As a statistics collection tool, iostat is valuable to any system administrator.

This article will cover installing and using iostat on a Linux server.

Start

To complete this article, you need the following:

  • dedicated server based on Linux

Manual

Installation process iostat very simple. iostat is part of the sysstat package, which can be installed on your respective system using one of the commands below:

CentOS

yum install sysstat

Ubuntu / Debian

sudo apt-get install sysstat

Running IOSTAT

IOSTAT tool that is available through the command iostat… Enter this command to see how it works:

iostat

Here is an example of the output from the iostat command:

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60 Device: tps Blk_read / s Blk_wrtn / s Blk_read Blk_wrtn sda 210.53 1022.33 1394.72 2214048305 3845623328 sda1 160.20 473.24 1422.29 1844686896 3295752889 sda2 21.00 320.12 145.21 1000012186 1668872653

While this report may seem very complicated at first glance, it is actually quite simple. We will explain, section by section, every aspect of the IOSTAT report, so you can easily use the reports for yourself:

Section 1: CPU Report

In the first part of the report (area with percentage values), you will find CPU statistics. Here we break down the statistics you find for you. For relevant statistics, we’ve added useful data in bold so you can see what the review includes:

With regard to CPU usage at the user / application level with and without priority, and at the system / kernel level:

  • % user: This column displays the percentage of CPU utilization that occurred during execution at the user / application level.
  • % nice: This column also displays the percentage of CPU utilization that occurs at runtime at the user level, but this time with a good priority. This means that only commands are invoked with the Linux command, which lowers the priority below the standard level shown in these statistics.
  • % system: In this column, you can see the percentage of CPU utilization that occurs at runtime at the system (also known as the kernel) level, in contrast to the statistics above.

Regarding CPU idle and latency:

  • % iowait: This statistic is the percentage of time that the processor or processors were idle during which the system had an outstanding disk I / O request.
  • % steal: The second in the last column continues to show the percentage of time that the virtual processor or processors spent waiting in spontaneously while the hypervisor was serving another virtual processor.
  • % idle: The last column in this section shows the percentage of time that the processor or processors were idle and the system did not have a disk I / O (input / output) request.

Section 2: Device Usage Report

The second part of the IOSTAT report, which is many times larger than the first section, lists all devices and displays statistics that relate to their use. This section is read horizontally, with each line showing statistics for the corresponding device:

  • Device: The very first column shows the name of the device or partition as listed in the / Dev directory.
  • tps: The next column shows statistics for this device, and displays the number of transmissions per second (tps) that were sent to the device. Busy processors will have more.
  • Blk_read / s: This statistic, read units per second, shows the amount of data read from the device, as expressed in a number of units (eg, kilobytes) per second.
  • Blk_wrtn / s: Likewise, blocks of writing per second are shown with the amount of data being written to the device also expressed in a number of blocks (such as kilobytes) per second.
  • Blk_read: The total number of blocks read for each device is shown in the second in the last column.
  • Blk_wrtn: Likewise, the total number of blocks written for each device is displayed in the last column.

Advanced IOSTAT report

1.Show megabyte instead of byte

By default, the IOSTAT input and output system measures in single bytes. But as soon as the byte gets small, for easier human digestibility, we can transform the report to display reports with megabytes, which are much larger and much easier to understand at a glance. Calling IOSTAT using the -m flag to display the megabyte inside reports:

iostat -m

Notice how the output is currently being modified, as shown in this sample output:

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60 Device: tps MB_read / s MB_wrtn / s MB_read MB_wrtn sda 210.53 0.63 0.74 1033680 1732461 sda1 160.20 0.28 0.64 1102131 1104562 sda2 21.00 0.16 0.14 392451 321456

2. Advanced withdrawal status

While the initial report still contains a lot of useful information, we can get even more information by using the -x flag with the IOSTAT command in order to display advanced reports:

iostat -x

The IOSTAT output will now also include an expanded statistic I / O disk, as shown in this example below. Note that we showed the output wrapped in the header information line for device columns is very large compared to earlier:

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60 Device: rrqm / s wrqm / sr / sw / s rsec / s wsec / s sda 7684.00 19.00 2321.00 523.00 81848.00 5287.00 avgrq-sz avgqu-sz await svctm% util 29.86 32.99 11.17 0.34 100.00

To understand what the new extended columns mean, you can look at the man page for IOSTAT, or with the command:

man iostat

3. Run IOSTAT with delay

You can tell IOSTAT to accept multiple reports with a delay, known as an interval. This is done using the OPTIONS parameter assigned to the IOSTAT command. However, if only the INTERVAL parameter is specified, then IOSTAT will continuously generate reports on this interval until you stop it! Thus, we will also provide a second parameter known as the COUNT parameter, which is also a number.

They are provided by IOSTAT as:

iostat [OPTIONS] [INTERVAL] [COUNT]

For an example of a situation where we want to generate three reports with a three-second interval between messages, and display in megabytes, run the following command:

iostat -m 3 3

The last two digits in the above command represent the interval parameter and the count parameter. The interval parameter, the first 3 in the example, tells the IOSTAT to wait three seconds between each report, with each subsequent report containing statistics for the time since the previous report. The counter parameter, second 3 in the example, tells IOSTAT how many reports should be generated in total. Returning to our example, the output should look something like this:

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60 Device: tps MB_read / s MB_wrtn / s MB_read MB_wrtn sda 210.53 0.62 0.74 1022670 1752461 sda1 160.20 0.29 0.64 1012132 1204462 sda2 21.00 0.17 0.14 394452 312446

In three seconds.

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60 Device: tps MB_read / s MB_wrtn / s MB_read MB_wrtn sda 210.53 0.62 0.74 1022670 1752461 sda1 160.20 0.29 0.64 1012132 1204462 sda2 21.00 0.17 0.14 394452 312446

After another three seconds.

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60 Device: tps MB_read / s MB_wrtn / s MB_read MB_wrtn sda 210.53 0.62 0.74 1022670 1752461 sda1 160.20 0.29 0.64 1012132 1204462 sda2 21.00 0.17 0.14 394452 312446

4. Display only one report per section

IOSTAT also allows you to change the report, show only the first section of the CPU or only the section of the second disk. In order to show only CPU statistics, we can use the -c flag with IOSTAT with the command:

iostat -c

We will use an example of a situation in which we want to display the CPU section only using two-second intervals and display the information five times (that is, make a total of five reports from one report every two seconds for the CPU section only). To do this, run the following command:

iostat -c 2 5

The output will look something like this:

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60

In two seconds.

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60

In another two seconds.

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60

In another two seconds.

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60

In another two seconds.

Linux 2.6.32x86_64 (dev-db) 03/01/2016 avg-cpu:% user% nice% system% iowait% steal% idle 4.00 0.00 0.40 1.00 0.00 94.60

Output

This guide has shown the basics of using IOSTAT system monitoring and statistics tool for your Linux system. More information on possible changes to the reports can be found in the online manual page for IOSTAT, with which you can get the most benefit.

If you found this introduction to IOSTAT helpful, please share it with your friends!

Sidebar