diskstats plugin

This plugin provides an interface to the /proc/diskstats file on kernel >= 2.6.

diskstats(device, key, delay)parse /proc/diskstats

device is a disk device name, e.g. 'hda' (do a cat /proc/diskstats for valid names on your system)

key is one of the following:

majormajor device number
minorminor device number
namedevice name (same as key)
reads# of reads issued
read_merges# of reads merged*
read_sectorsnumber of sectors read
read_ticks# of milliseconds spent reading
writes# of writes completed
write_merges# of writes merged*
write_sectorsnumber of sectors written
write_ticks# of milliseconds spent writing
in_flight# of I/Os currently in progress
io_ticks# of milliseconds spent doing I/Os
time_in_queueweighted number of milliseconds spent doing I/Os

*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 it will be counted (and queued) as only one I/O. This field lets you know how often this was done.

If you want to know the exact meaning of all the keys, I'm afraid you have to dig into the kernel sources. Or someone with deeper kernel knowledge can edit the table….

Note that read_sectors and write_sectors (the most important keys) return a number of sectors. To get the number of bytes, you have to multiply this value by the sector size (usually 512).

The delay value specifies a period of time (in milliseconds) for a delta computation. If you use a delta of 0 (zero), you get the absolute values (same as in /proc/diskstats). For delay values > 0 you get the delta value in 1/sec unit. Using a delta value of 500 msec seems to be a good choice.

Note that the device field is interpreted as a regular expression (regex), if you use a regex you get the sum of all matching devices (e.g. diskstats ('hd.', 'read_sectors', 500) will return the sum of read sectors for hda, hdb, hdc, …)

Kernel 2.4: Kernel 2.4 does not provide a /proc/diskstats file. Use the proc_stat plugin instead!

Widget Disk {
    class      'Text'
    expression  diskstats('hd.', 'read_sectors', 500) + diskstats('hd.', 'write_sectors', 500)
    prefix     'IDE'
    width       10	
    precision   0
    align      'R'	
    update      300	

  • plugin_diskstats.txt
  • Last modified: 2020/07/17 18:33
  • (external edit)