My requirement is to profile current process disk read/write operations with total disk read/write operations (or amount of data read/written). I need to take samples evry second and plot a graph between these two. I need to do this on Linux (Ubuntu 12.10) in c++.
Are there any APIs/Tools available for this task ? I found one tool namely iotop
but I am not sure how to use this for current process vs system wide usage.
Thank You
You can read the file
/proc/diskstats
every second. Each line represents one device.From kernel's "Documentation/iostat.txt":
For each process, you can get use
/proc/<pid>/io
, which produces something like this: