2
Say I have a program that writes to a bunch of places on the filesystem. It runs from a single executable. I want to determine, at any point in its run (it runs for a long time), how many bytes it has written to the disk.
Most people seem to like tools like pv
for this task, but it won't work for my case, because the executable in question writes to many different places out on the filesystem, if I were to write my_exec | pv <whatever> | cat
or whatnot, my_exec
would just write out a big blob of data, without parsing it out into folders as it should.
Similarly, stuff like iotop
isn't what I'm after, as I would like to be able to attach/detach a "watcher" to my IO heavy process.
I'm aware the question seems confusing, perhaps an example would help. What I'd like to do is something like this.
my_exec &
local exec_pid = $?
mystery_command ${exec_pid} # continuously writes out the number of bytes
# written to disk by my_exec since the invocation
# of mystery_command
Or, alternatively, something that wraps/watches another arbitrary command, like this:
{ my_exec } | mystery_command # my_exec will still write to folders as it
# should, but mystery_command will continuously
# output the number of bytes written to disk by
# the attached {} group.