Monitoring with Iostat

Monitoring Linux with Iostat

Monitoring with iostat

iostat is a linux performance command line monitoring tool. By default the first report generated from the iostat command provides statistics relating to the time since the system was booted. Each following report then covers the time since the previous report. All statistics are reported each time the iostat command is run. The basic report consists of a CPU header row followed by a row of CPU statistics. On a multiprocessor system, CPU statistics are calculated system-wide an average among all of the processors. A device header row is displayed followed by a line of statistics for each device that is configured.

The basic syntax for the iostat command is : iostat [ options ] [ <interval> [ <count> ] ]

The interval specifies the amount of time between each report. The first report will always contain the time since system startup (boot). Each subsequent report will then contain stats that have been collected during the previous interval. The count parameter specifies how many reports to generate.

The following is output from an iostat command running on my Ubuntu 12.04 LTS desktop: iostat -p sda 2 2

iostat monitoring tool

This command will generate two reports for the device sda and any of its partitions (sda1,2..) at an interval of every two seconds.

Various options can be passed to the iostat command to modify show only the information required:

-c Display the CPU utilization report.

-d Display the device utilization report.

-h Make the Device Utilization Report easier to read by a human.

-k Display statistics in kilobytes per second.

-m Display statistics in megabytes per second.

-N Display the registered device mapper names for any device mapper
devices. Useful for viewing LVM2 statistics.
-p [ { device [,...] | ALL } ]

For example: iostat -c 2 5

This would display five reports of CPU information at two second intervals. (see example below)

john@john-desktop:~$ iostat -c 2 5
Linux 3.2.0-37-generic (john-desktop) 14/02/13 _i686_ (1 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
21.60 0.85 5.09 2.63 0.00 69.84

avg-cpu: %user %nice %system %iowait %steal %idle
0.50 0.00 0.50 0.00 0.00 98.99

avg-cpu: %user %nice %system %iowait %steal %idle
0.50 0.00 0.00 0.00 0.00 99.50

avg-cpu: %user %nice %system %iowait %steal %idle
0.50 0.00 0.50 0.00 0.00 98.99

avg-cpu: %user %nice %system %iowait %steal %idle
0.51 0.00 0.51 1.01 0.00 97.98

For a full list of all the available options and parameters, consult the man pages by issuing: man iostat.