I want to measure some numbers related to disk io in a given timespan, programmatically. This means I don't want to spawn a process like iostat to get my numbers, by prefer to read something from proc or the like.
I need to know:
- The number of blocks written to disk
- The number of blocks read from disk
- The number of blocks read from disk but found in the disk cache
- The number of blocks about to be written to the disk, but not written yet, to know how much succeeding IO I might expect.
If I only get this information by disk or partition... this is even better, since I don't need to know how much information I read from proc.
If I additionally know how much time the process has waited for the IO to be done... even better.
Is this possible with some IO calls, or by reading and parsing the /proc files?
iostat reads from
/proc/diskstats
- I can't tell you which column corresponds to what though. That would take a bit of investigation. Additionally, if you'd like to get more info about a specific process,/proc/[processID]
contains information pertaining to the process, such as io and memA line in the file looks like:
From
/usr/src/linux-*/Documentation/iostats.txt
: