The iostat command stands for input-output statistics. This command is used to generate input-output statistics for device, partitions the network file system, generate the report for Central Processing Unit (CPU). When the system booted, iostat command generates the first report. Each report follows the same time as the previous one. These report followed by the CPU statistics. When you consider a multi-processor system, the CPU statistics are calculated by average all processor. Each interval parameter takes to generate the report in seconds; we can specify ‘count’ parameter the junction point of each interval parameter.
Before using the iostat command, you need to install Sysstat package. Sysstat package help to configure iostat command and you need to check the latest version of iostat are available on your system or not. Sysstat store different type of commands like

1) sar command
2) sadc
3) a1
4) sa2
5) iostat
6) mpstat etc.

Syntax for iostat command

$iostat <options> <device name>

1.Cpu and Device utilization statistics:

In this article, if you only display the information about CPU usage, input-output statistics, then use the simple iostat command. The syntax is given below:

$iostat

Example 1:

[linuxnix@fedori ~]$iostat                                                     
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)         
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.55                         
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
sda               7.67        23.85        64.13  989350866 2659823200         
sdc               0.00         0.00         0.00       7768         34         
sdb               0.88         8.10        11.69  336111312  484965258  

 

Only partitions are entered into command line but in this section –x option is not used. If there is neither partition nor device is given, then every device used by the system and providing the kernel for maintenance purpose. The report completely depends on the following fields, where flags are used; tps indicates the number of transfer per seconds issued by the device. Blk_read/s show the number of data read from a drive in a number of blocks per seconds. Next, Blk_wrtn/s indicates the amount of data written from a drive in a number of blocks per seconds. Blk_read and Blk_wrtn mean the total amount of block read and writes.

2.CPU statistics:

In CPU statistics, use iostat –c command. The advantage of this command is, you can generate the CPU utilization report.

$iostat -c

Example 2:

[linuxnix@fedori ~]$iostat -c                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.55    

 

If you want to see CPU utilization in 4 seconds interval with 5 times report, then the syntax will be

$iostat –c [interval] [interval]

Example 3:

[linuxnix@fedori ~]$iostat -c 4 5                                              
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.55                        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
          16.50    0.00   12.25    0.00    0.00   71.25                        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           0.25    0.00    0.00    5.51    0.00   94.24                        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           0.00    0.00    0.25    1.50    0.00   98.25                        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           0.25    0.00    0.75    5.49    0.00   93.52      

3. Disk Input-output statistics:

When you want to see the performance of disk input-output statistics, and then use this syntax as follows. The advantage of this command is that you can display device utilization report using this command.

$iostat -d

Example 4:

[linuxnix@fedori ~]$iostat -d                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
sda               7.67        23.85        64.13  989350882 2659828416         
sdc               0.00         0.00         0.00       7768         34         
sdb               0.88         8.10        11.69  336111312  484966130     

 

If you want to show disk input-output under hda3 and hda6 only with 3 seconds interval and 5 times report, here hda3 and hda6 are two type of devices.

$iostat –d hda3 hda6 [interval] [interval]

Example 5:

[linuxnix@fedori ~]$iostat -d hda3 hda5 3 5                                    
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn 

 

4.Network statistics:

This section is very interesting because this section gives you the information about the network file system. The advantage of this command is that only this command works with the kernel.

$iostat –n

Example 6:

[linuxnix@fedori ~]$iostat -n                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
Filesystem:              rBlk_nor/s   wBlk_nor/s   rBlk_dir/s   wBlk_dir/s   rB
lk_svr/s   wBlk_svr/s     ops/s    rops/s    wops/s                            

If you use iostat –N command then it gives a different output, because N displays the registered device which mapped between devices.

$iostat -N

Example 7:

[linuxnix@fedori ~]$iostat -N                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)         
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
sda               7.67        23.85        64.13  989350890 2659838360         
sdc               0.00         0.00         0.00       7768         34         
sdb               0.88         8.10        11.69  336111312  484967994 

 

5. Display value in megabytes and kilobytes:

Sometimes you need to display the variable in megabytes and the syntax format of this command given below. This section is very useful because a variation of –m or –k commands, you can display the device statistics in megabyte/seconds or kilobyte/seconds.

$iostat -m

Example 8:

[linuxnix@fedori ~]$iostat -m                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn         
sda               7.67         0.01         0.03     483081    1298750         
sdc               0.00         0.00         0.00          3          0         
sdb               0.88         0.00         0.01     164116     236801  

 

you can also display those values in kilobytes and the syntax format of this command given below

$iostat -k

Example 9:

[linuxnix@fedori ~]$iostat -k                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn         
sda               7.67        11.93        32.06  494675445 1329921328         
sdc               0.00         0.00         0.00       3884         17         
sdb               0.88         4.05         5.85  168055656  242484513   

 

If you want to display kilobytes in 3 seconds interval with 2 times report, syntax is given below

$iostat –k [interval] [interval]

Example 10:

[linuxnix@fedori ~]$iostat -k 3 2                                              
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn         
sda               7.67        11.93        32.06  494675445 1329921892         
sdc               0.00         0.00         0.00       3884         17         
sdb               0.88         4.05         5.85  168055656  242484645         
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           0.67    0.00    0.33    3.01    0.00   95.99                        
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn         
sda               2.68         1.34        16.05          4         48         
sdc               0.00         0.00         0.00          0          0         
sdb               0.00         0.00         0.00          0          0  

You can also display n number of parameter, by using –x command. This command helps us to display the extended statistics. This section is also working with the older kernel.

$iostat -x

Example 11:

[linuxnix@fedori ~]$iostat -x                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgq
u-sz   await  svctm  %util                                                     
sda               0.05    13.70    0.41    7.26    23.85    64.13    11.47     
0.05    6.81   4.39   3.37                                                     
sdc               0.00     0.00    0.00    0.00     0.00     0.00     8.02     
0.00   20.24  17.38   0.00                                                     
sdb               0.08     1.16    0.58    0.30     8.10    11.69    22.62     
0.09  105.82  14.14   1.24          

Here, rrqm/s indicates a number of reading requests merged per seconds. Next wrqm/s display the number of write request merged per seconds. r/s indicates only the number of read request and w/s indicates the number of write request per seconds. Here all of those requests are considered for a device. Now, rsec/s and wsec/s indicates the number of reading sector and a number of write sector per seconds. Finally avgrq-sz displays the average number of request for each sector.

6. Input-output statistics for a single device:

This section generates the information about the related input-output statistics for a single device by using –p sda command. Using this command you can display all partition of a device. Here sda is one type of device name. The following syntax

$iostat –p sda

Example 12:

[linuxnix@fedori ~]$iostat -p sda                                              
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)         
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                         
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
sda               7.67        23.85        64.13  989350906 2659847072         
sda1              0.34         4.80        36.90  199235634 1530646600         
sda2              0.02         0.13         0.18    5466606    7354224         
sda3              6.06        10.05         8.63  416702754  358127952         
sda4              0.00         0.00         0.00         20          0         
sda5              0.47         0.00         6.11      67010  253298104         
sda6              0.78         8.87        12.29  367715562  509967104         
sda7              0.00         0.00         0.01     161736     453152         
sda8              0.00         0.00         0.00        296          0  

7. Time statistics:

Using –t command you can display the timestamp information for any type of system. The advantage of this command is that it can display the time for each report generation. Syntax format of this section given below:

$iostat -t

Example 13:

[linuxnix@fedori ~]$iostat -t                                                  
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)         
07/19/2016 07:18:34 PM                                                         
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
sda               7.67        23.85        64.13  989350906 2659849096         
sdc               0.00         0.00         0.00       7768         34         
sdb               0.88         8.10        11.69  336111536  484970266   

8. Display version:

In this section, you can display the exact version of iostat, by using –V command

$iostat -V

Example 14:

[linuxnix@fedori ~]$iostat -V                                                  
sysstat version 9.0.6.1                                                        
(C) Sebastien Godard (sysstat <at> orange.fr)    

9. Display Block device:

You can also display all block devices with their partition by using all command and the syntax format is

$iostat -all

Example 15:

[linuxnix@fedori ~]$iostat all                                                 
Linux 2.6.35.14-106.fc14.i686 (fedori)  07/19/2016      _i686_  (1 CPU)        
avg-cpu:  %user   %nice %system %iowait  %steal   %idle                        
           6.38    9.74   10.47    1.86    0.00   71.56                        
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn         
The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.