iotop is a tool to monitor I/O usage, it works with the Linux kernel starting at version 2.6.20. By default iotop works on a per-thread basis and shows information for each thread individually. This tool requires root access.
For the use case of analyzing a single program iotop offers the option to limit diagnostics to a single process. Replace
PID with your process-id.
iotop -p PID
While running in interactive mode you can toggle between showing all threads and only those doing I/O by pressing
For analyzing a single programs performance you might want to log the results instead of viewing them in interactive mode. Use the '–batch' or '-b' option and log the results to a file.
iotop -bp PID > iostats.log
By default the tool shows disk read- and write speed per thread as well as the percentage of time spent waiting for swap and I/O. The I/O priority is also displayed.
Below you see part of the output of
iotop while running
cat /dev/urandom > random.file.
Total DISK READ :0.00 B/s | Total DISK WRITE :13.45 M/s Actual DISK READ:0.00 B/s | Actual DISK WRITE:0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 4879 be/4 someuser 0.00 B/s 13.45 M/s 0.00 % 0.00 % cat /dev/urandom 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd]