yum install sysstat
The sysstat package contains the following utilities:
The iostat utility reads /proc/diskstats and computes the differences between samples generating the report output.
8 0 sda 78303 13823 2367864 1026600 1524640 1927639 27624132 19618067 0 6384461 20643742 A B C 1 2 3 4 5 6 7 8 9 10 11
- A = Major number
- B = Minor number
- C = Disk name
- 1 - 11 field numbers ==> /usr/share/doc/kernel*/Documentation/iostats.txt file,
yum install kernel-doc
IOPS = r/s (field 1) + w/s (field 5),
iostat -d or
- Field 1 - This is the total number of reads completed successfully.
- Field 2 & 6 - Reads and writes which are adjacent to each other may be merged for efficiency. Thus two 4K reads may become one 8K read before it is ultimately handed to the disk, and so itwill be counted (and queued) as only one I/O. This field lets you know how often this was done.
- Field 3 - This is the total number of sectors read successfully.
- Field 4 - This is the total number of milliseconds spent by all reads (as measured from __make_request() to end_that_request_last()).
- Field 5 - This is the total number of writes completed successfully.
- Field 7 - This is the total number of sectors written successfully.
- Field 8 - This is the total number of milliseconds spent by all writes (as measured from __make_request() to end_that_request_last()).
- Field 9 - I/Os currently in progress. The only field that should go to zero. Incremented as requests are given to appropriate struct request_queue and decremented as they finish.
- Field 10 - Number of milliseconds spent doing I/Os. This field is increases so long as field 9 is nonzero.
- Field 11 - Weighted number of milliseconds spent doing I/Os. This field is incremented at each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/Os in progress (field 9) times the number of milliseconds spent doing I/O since the last update of this field. This can provide an easy measure of both I/O completion time and the backlog that may be accumulating.
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await r_await w_await svctm %util sda 0.00 112.00 0.00 130.00 0.00 1936.00 14.89 1.74 13.36 0.00 13.36 0.19 2.50
- rrqm/s = (/proc/diskstats field 2)
- wrqm/s = (/proc/diskstats field 6)
- r/s = (/proc/diskstats field 1)
- rsec/s = (/proc/diskstats field 3) - each sector 512 bytes (use "-k" or "-m" for KB/s or MB/s)
- w/s = (/proc/diskstats field 5)
- wsec/s = (/proc/diskstats field 7) - each sector 512 bytes (use "-k" or "-m" for KB/s or MB/s)
- avgrq-sz = (rsec/s + wsec/s) / (r/s + w/s)
- avgqu-sz = (/proc/diskstats field 11)
- await = (/proc/diskstats field 4 + 8 / field 1 + field 5)
- r_await = (/proc/diskstats field 4)
- w_await = (/proc/diskstats field 8)
- svctm = (%util * 1000ms) / (r/s + w/s)
- %util = (/proc/diskstats field 10) - (r/s + w/s ) * svctm / 10
- Display the device utilization, in extended format, in megabytes, omit devices with no activity, LVM2 statistics, print the time for each report :
iostat -xm | grep Device; iostat -xmNtdz 1 | grep <device>
- Display de device utilization and save all statistics in a file:
iostat -xt 1 | tee $(hostname)-iostat.txt
- Monitor a specific disk:
iostat -x 1 /dev/sdaor
iostat -x 1 | grep -E 'Device|dm-13'
export S_TIME_FORMAT=ISO;iostat -tNxm 1 3600 > $(hostname)-iostat.txt