Top/free/df equiv for 'monitor disk IO'?

I can use:

  • 'top' to measure CPU usage
  • 'free' to measure RAM usage
  • 'df' to measure disk usage

Is there a crate that does something similar, but measures disk IO ? I only need it to run on x86_64.

Context: Playing with a bitcask implementation. Bitcask has a "garbage collect / compact" phase. I want to have a separate thread that monitors disk IO, and runs the gc / compact phase when there is little disk IO going on.

Is iotop what you're looking for? Packaged in most distros.

Edit: sorry, I definitely missed that you were looking for runtime Rust code rather than a userland utility.

There is a crate like procfs which is an interface to /proc on Linux. That’s the crate that procs uses for example. And specifically, the Io struct should have the info you’re looking for for a given process. If you want bytes/sec written for example, you can query it every second and calculate the change in the wchar value.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.