Master Linux I/O Monitoring: iostat, iotop, and lsof Explained
Learn how to diagnose and alleviate heavy I/O load on Linux systems by using three essential commands—iostat for CPU and disk statistics, iotop for real‑time I/O process ranking, and lsof for listing open files—complete with key options and output interpretation.
Introduce three commonly used Linux I/O commands that are useful for solving excessive I/O pressure.
iostat
Outputs CPU and disk I/O related statistics.
Average‑CPU section %user: percentage of CPU used by user programs %nice: percentage of CPU used by nice‑adjusted processes %sys: percentage of CPU used by the system %iowait: percentage of CPU waiting for I/O %idle: percentage of idle CPU time
Device section tps: I/O requests per second Blk_read/s: blocks read per second Blk_wrtn/s: blocks written per second Blk_read: total blocks read Blk_wrtn: total blocks written
Common parameters -c: display only CPU statistics (mutually exclusive with -d) -d: display only disk statistics (mutually exclusive with -c) -k: show values in kilobytes per second (default unit is blocks) -p device|ALL : show statistics for a specific device or all devices -x: display extended information sec: interval in seconds between displays
iotop
A top‑like tool for monitoring disk I/O usage, showing PID, user, I/O, and command information.
iotop is not included by default; install it (e.g., yum install iotop on CentOS).
Main options -o: display only processes doing I/O -b: batch mode, suitable for logging to a file -n NUM : display NUM iterations (non‑interactive mode) -d SEC : refresh interval in seconds -p PID : monitor a specific process ID -u USER : monitor processes owned by a specific user
lsof
lsof(list open files) lists files opened by processes; it requires root privileges to access full information.
lsof is not installed by default; install it (e.g., yum install lsof on CentOS).
Output fields COMMAND: process name PID: process identifier USER: process owner FD: file descriptor TYPE: file type (e.g., DIR, REG) DEVICE: device name SIZE: file size NODE: inode number NAME: exact name of the opened file
Common usage examples lsof abc.txt: show processes that have abc.txt open lsof -c abc: show files opened by processes whose command name contains abc lsof -p 1234: list files opened by process ID 1234 lsof -g gid: show processes belonging to group ID gid lsof +d /DIR/: list files opened under directory /DIR/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
