Display the number of I/O to disk (reads/writes) since the last boot on CentOS

Posted on

Display the number of I/O to disk (reads/writes) since the last boot on CentOS – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, storage, , , .

Is it possible to use iostat (or some other tool) to get the number of reads/writes operation “since the last server reboot”?

I mean: I’d need to know how many reads/writes the server has done since the last boot, not in realtime.

Thanks!

Solution :

For the amount of data, see iostat:

[root@example ~]# iostat -m
Linux 2.6.32-431.11.2.el6.x86_64 (example.com)  08/08/2014  _x86_64_    (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.38    0.00    4.10    0.36    0.10   95.07

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda               0.95         0.01         0.01      68451      77290
vda              13.95         0.26         0.33    2871276    3572093
dm-0              1.93         0.01         0.01      64657      73426
dm-1             14.39         0.26         0.33    2871274    3572093

-m will display the output in MiB (instead of blocks), and the MB_read, MB_wrtn are the numbers you are looking for.

For the total amount of I/O operations (requests), see /sys/block/$DEV/$PART/stat, e.g. /sys/block/sda/sda1/stat or /proc/diskstats, which can be interpreted as follows (this is from the kernel doc tree):

What:       /proc/diskstats
Date:       February 2008
Contact:    Jerome Marchand <jmarchan@redhat.com>
Description:
        The /proc/diskstats file displays the I/O statistics
        of block devices. Each line contains the following 14
        fields:
         1 - major number
         2 - minor mumber
         3 - device name
         4 - reads completed successfully
         5 - reads merged
         6 - sectors read
         7 - time spent reading (ms)
         8 - writes completed
         9 - writes merged
        10 - sectors written
        11 - time spent writing (ms)
        12 - I/Os currently in progress
        13 - time spent doing I/Os (ms)
        14 - weighted time spent doing I/Os (ms)
        For more details refer to Documentation/iostats.txt

Leave a Reply

Your email address will not be published.