Sunday, November 30, 2014

Disk Monitoring (Part 1)

Hello All,
Today, I would like to talk about a monitoring tool for physical disks (iostat). It is a very great tool if you want to watch and improve your disk's performance. It monitors system input/output device loading by observing the time the devices are active in relation to their average transfer rates. Therefore, it can be used to change system configuration to better balance the input/output load between physical disks.

iostat
To find out which package contains iostat utility, run the below command:
yum whatprovides "*/iostat"

                                                                          Figure 1


Install iostat:
yum install sysstat

Running iostat without any parameters will make a report at the time of running command (just one instance):

                                                                           Figure 2

It generates two types of reports, the Cpu Utilization report and the Device or Disk Utilization report.

According to man page,
%user : Show the percentage of CPU utilization  that  occurred while executing at the user level (application).
%nice : Show  the  percentage of CPU utilization that occurred while executing at the user level with nice priority.
%system : Show the percentage of CPU utilization that occurred while executing at the system level (kernel).
%iowait : Show  the  percentage  of  time that the CPU or CPUs were idle during which the system had an outstanding disk  I/O request.
%steal : Show  the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was  servicing another virtual processor.
%idle : Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk  I/O request.

tps : Indicate the number of transfers per second that were issued to the device.
kB_read/s : Indicate the amount of data read from the device expressed in kilobytes per second.
kB_wrtn/s : Indicate the amount of data written to the device expressed in kilobytes per second.
kB_read : The total number of blocks read.
kB_wrtn : The total number of blocks written.

If you want to make a report just for Cpu utilization, use "-c" parameters OR use just "-d" for Device Utilization:
iostat -c
iostat -d


To display statistics in megabytes per second use "-m":

                                                                            Figure 3


To run iostat command continuously, we need an interval parameter without any count parameter. For example, to run iostat each every 3 senonds continuously, we need the below command:

iostat -d 3

                                                                            Figure 4

To run iostat command by specifying the amount of time in seconds between each report and stops after some number of counts, we need a count paramater after interval parameter. For example, to generate a report running in each 3 seconds and stops after 2 counts, we need the below command:

iostat -d 3 2


                                                                              Figure 5


Use "-x" parameter to extend the report for more statistics:

iostat -x


                                                                               Figure 6

If you need statistics just for one specific disk, for example dm-0, run the below command:

iostat -x dm-0


                                                                               Figure 7

Disadvantage of iostat command is that you can't find out which process or application is acting up or causing issues on that particular device if there is. In next part, I will talk about iotop command to address this.
Hope you enjoyed,
Khosro Taraghi