I'm trying to measure the total amount of disk writing and reading that is done to a particular volume by a particular process over a specified duration.
I've found iotop, which can output IO every second for a particular process like this:
iotop --batch --pid $(pidof my_process)
Where you can specify x iterations with -n x
.
But then I have to filter out the actual number, and tally it up myself.
Is there an easier way to do this?
Don't know of an easier way off hand, but this bash snippet might help you with parsing out what you need from iotop:
Actually, Might be easier to read /proc/$PID/io every x seconds:
Actually, looks like the above script is wrong, because it seems like
/proc/<pid>/io
is just the total, so really, just grab it once, wait however long, grab it again, find the differnce and there is your answer. You might want to look at the source code and find out its data type to see if it eventually wraps around. Probably not a problem for a little tablet though.It might be over kill, and you might need to customize a plugin, but you could try "Munin", which is a graphing application that does just what you need.
It does not have a plugin for per process IO, but I'm sure hacking one up is not too hard. You'll then get all the added value of munin/rrdtool with avereges over day/week/year, graphing, limits, warnings, etc.
You can install
sysstat
with apt-get in most Debian-based distros, including Maemo, and runiostat
to monitor disk read/write totals.Just make sure nothing else is writing to the disk, which may or may not be possible in your situation.
iostat
prints total Blocks read and written since bootup, or some other arbitrary point in time. You have to figure out how big a block is to know how much data is written.I did this by having
dd
write a known amount of data, and dividing the blocks.