Is there a tool like iotop
but for monitoring IO on specific volumes? (Or perhaps I missed a way to filter iotop
?) If not is there any way to get at this information via (say)/proc
? (dstat
etc. only show aggregate activity across all processes per volume, whereas I'm interested in seeing how much each process is contributing.)
4 Answers
Check out fatrace
:
For example, cd into the partition you want to (in my case, mount point /hdd
) monitor and run
sudo fatrace -c -t
Then, for example a touch /hdd/x
will show:
16:11:05.278541 touch(179482): + /hdd
16:11:05.278541 touch(179482): CWO /hdd/x
Details:
Usage: fatrace [options...]
Options:
-c, --current-mount Only record events on partition/mount of current directory.
-o FILE, --output=FILE Write events to a file instead of standard output.
-s SECONDS, --seconds=SECONDS Stop after the given number of seconds.
-t, --timestamp Add timestamp to events. Give twice for seconds since the epoch.
-p PID, --ignore-pid PID Ignore events for this process ID. Can be specified multiple times.
-f TYPES, --filter=TYPES Show only the given event types; choose from C, R, O, or W, e. g. --filter=OC.
-C COMM, --command=COMM Show only events for this command.
-h, --help Show help.
This isn't an ideal answer, but this will tell you, every second, what process wrote the most, and how much it wrote, to a given disk (in this case /dev/sda
):
dstat -tdD /dev/sda --top-io
You'll see something like:
-
2this is helpful but it doesn't seem to limit the io reporting to the disk you specify... no matter what disk I pass on the command line, the top io process comes up.– stuNov 8, 2021 at 19:56
-
1oh I see, the io on the disk is on the left, the process is on the right, and the process isn't limited to the specified disk, but the read/write on the left is. thanks– stuNov 8, 2021 at 19:58
-
1@stu Yes, exactly. There may be IO to other disks too, but this should be only for the disk you specify. Nov 10, 2021 at 16:00
-
hmmm... getting back to this, it looks now like I read this wrong. the process is the most expensive process overall (including all disks it writes to) and the io going to the disk is on the left, but that doesn't actually mean that the most expensive process is the one doing all the writing to the disk in the left column, does it? really hard to read.– stuJan 11, 2022 at 15:56
-
1for anybody else looking, I hadn't heard of fatrace, it doesn't tell you how much data is moving, but it does tell you what files, and you can limit it to a filesystem.– stuJan 14, 2022 at 0:28
As there are no answers yet...
I do not have an easy suggestion (like an iotop switch) but if this is important to you then you may write a FUSE module which just remounts the file systems elsewhere (chroot for the process to be examined) and counts the amount of data read / written. That should be a rather easy adaption of existing modules. You may ask the FUSE community which might be the best existing solution to start from. Probably even their demo module will do.
You can use iostat to monitor disk I/O for performance issues.
$ iostat -xd /proc
-
5that splits up activity by disc, but not by process which is the key feature of iotop Nov 29, 2017 at 13:09
-
Why add
-d /proc
? That will never give anything afaict, because/proc
is not a device. You'd want to run it without that to see all devices, i.e.iostat -x
. Heck, even the-x
can be left out if you're not looking for obscure stats like "aqu-sz". Other than that, though, this is the tool I was looking for. It doesn't do by process, but I have one process reading from multiple disks and dominating my iotop stats, so I can estimate how much data is read from each device. Thanks!– LucMay 11, 2019 at 12:10