Can htop show disk I/O metrics per process?
The htop command-line tool can display disk I/O metrics
for individual processes, but this capability requires specific system
configurations and kernel support. While htop is
traditionally celebrated for its real-time CPU and memory monitoring, it
also features dedicated, customizable columns for tracking read and
write speeds per process. This article explores how to view these
metrics within htop, details the prerequisites needed for
them to function, and introduces alternative command-line utilities
specifically designed for dedicated storage performance tracking.
Enabling Disk I/O Columns in htop
By default, htop does not show disk input/output data in
its primary interface. To view these metrics, you must manually add the
relevant columns to your display via the setup menu.
- Launch
htopin your terminal. - Press F2 (or S) to enter the Setup menu.
- Use the arrow keys to navigate down to Columns in the “Setup” left-hand pane.
- Move to the Available Columns right-hand pane and scroll down until you find the I/O metrics.
- Select IO_READ_RATE (the speed at which the process is currently reading from disk) and press F5 to add it to your visible columns.
- Select IO_WRITE_RATE (the speed at which the process is currently writing to disk) and press F5 to add it.
- Press F10 to save your changes and return to the main monitoring screen.
System Prerequisites and Limitations
Even after adding the columns, htop might display zeros
or fail to show accurate data if certain system criteria are not met.
The tool relies directly on the Linux kernel’s taskstats interface to
gather per-process I/O data.
- Kernel Configuration: The Linux kernel must be
compiled with taskstats and I/O accounting enabled. Most modern
mainstream distributions (like Ubuntu, Fedora, and Debian) have
CONFIG_TASK_DELAY_ACCTandCONFIG_TASK_IO_ACCOUNTINGenabled by default. - Root Privileges: Standard user accounts often lack
the administrative permissions required to read I/O infrastructure data
from the
/procfilesystem for all system processes. To guarantee accurate metrics,htopshould be executed with root privileges using thesudo htopcommand.
Alternative Commands for Disk I/O Monitoring
If you prefer a tool tailored entirely to storage performance without
adjusting configurations, several dedicated command-line utilities can
complement or replace htop for disk analysis.
- iotop: This tool functions almost identically to
htopbut is entirely dedicated to monitoring I/O. It provides a clean, real-time list of exactly which processes are consuming disk bandwidth, complete with read and write speeds. - pidstat: Part of the
sysstatpackage, runningpidstat -ddisplays a snapshot of I/O statistics for active processes, making it highly useful for scripting and historical logging.