Master Linux Performance Monitoring with iostat: Installation, Usage, and Advanced Tips
This guide explains how to install the iostat tool on various Linux distributions, demonstrates basic and advanced commands for monitoring disk I/O and CPU usage, interprets its output columns, and shows how to customize, redirect, and remotely collect performance data.
Installation
Most Linux distributions include iostat via the sysstat package; if it is missing, install it with the appropriate package manager.
sudo apt-get install sysstat sudo yum install sysstatBasic Usage
1 View overall disk and CPU statistics
Run iostat to display average CPU utilization and per‑disk I/O activity.
iostat2 Specify interval and count
Use -t to set the reporting interval in seconds and -c to set the number of reports.
iostat -t 2 5Understanding iostat output
The output contains several columns, including:
avg-cpu : average CPU usage statistics (user, system, idle).
Device : name of the disk device.
tps : transfers per second, i.e., number of I/O operations per second.
kB_read/s : kilobytes read per second.
kB_wrtn/s : kilobytes written per second.
%util : percentage of time the device was busy.
Example Commands
1 Monitor disk I/O
iostat -d -t 2 10This displays disk I/O statistics every 2 seconds, for a total of 10 reports.
2 Monitor CPU utilization
iostat -c -t 2 10This shows CPU utilization every 2 seconds, for 10 reports.
Advanced Usage
1 Monitor specific partition
iostat -p /dev/sda1 -t 2 10Monitors the I/O of the /dev/sda1 partition every 2 seconds, 10 times.
2 Custom output format (CSV)
iostat -c -o CSV -t 2 10Outputs CPU statistics in comma‑separated values.
3 Redirect output to a file
iostat -d -t 2 10 > iostat_output.txtSaves the disk I/O statistics to iostat_output.txt for later analysis.
4 Monitor network devices
iostat -n -t 2 10Shows network interface statistics every 2 seconds, 10 times.
5 Remote monitoring
iostat -d -t -h remote_hostConnects to remote_host and monitors its disk I/O.
6 Show block devices
iostat -k -t 2 10Displays I/O statistics for block devices every 2 seconds, 10 times.
7 Select specific columns
iostat -x -t 2 10Shows only the chosen columns (e.g., device, transfer rate, utilization) every 2 seconds, 10 times.
Conclusion
iostat is a powerful utility for tracking disk I/O and CPU performance, making it valuable for troubleshooting, performance tuning, and overall system health monitoring.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
