0

I want to count theIOs consumed by a command in Linux. For example, if I run 'ls' command, I should get IOs consumed by it.

I already tried help given here:

How to measure IOPS for a command in linux?

But, I am not able to get actual IO operations performed by command. I guess what I am getting is time taken by command to execute.

Please help regarding the same.

Dvyn Resh
  • 980
  • 1
  • 6
  • 14
atg
  • 204
  • 3
  • 18

1 Answers1

0

An application performs system calls (e.g., pread/pwrite) when reading/writing data from a file or block device. Sometimes these system calls result in actual IO at the level of the storage device, sometimes they do not. For reads, the data requested can be a served from the page cache. For writes, the data can be written to DRAM and then flushed asynchronously to the storage device.

You can use strace to see the system calls of an application. For example, to trace the IO-related system calls, something like strace -f -e file ls should print all file descriptor related system calls. You can redirect the output to a file and process it later.

Use iostat, e.g. iostat -d 1 -k -x, to see how much IO the storage device is seeing.

Radu
  • 1,098
  • 1
  • 11
  • 22
  • NB: [strace introduces a heavy performance overhead into whatever is being traced](http://www.brendangregg.com/blog/2014-05-11/strace-wow-much-syscall.html) – Anon Nov 06 '20 at 07:15