iostat
This command will produce output that shows the average CPU load and disk I/O statistics since the last system boot. The first section gives CPU usage percentages (user, system, idle, etc.), and the subsequent sections list I/O data for each device, including metrics such as
tps (transactions per second),
kB_read/s, and
kB_wrtn/s.
To monitor disk I/O in real-time, you can use the
-x flag for extended statistics and specify an interval. For example, to display updated statistics every 2 seconds:
iostat -x 2
This command will continuously refresh the output every 2 seconds, giving you a live view of CPU and I/O activity.
If you want to monitor a specific device, you can specify it by name. For example, to monitor only
/dev/sda, run:
iostat -x 2 /dev/sda
This will show statistics for the specified device only, which is useful if you are troubleshooting or monitoring a particular disk.
The
iostat tool can also display historical data collected by the
sysstat service. To view I/O activity from a previous day, use the
-h flag along with the
-p flag for partitions. For example:
iostat -h -p ALL
This will give you a detailed historical view of all devices and partitions.
Understanding Key Metrics:
await and
%util, it can indicate problems.
Regular Monitoring: Set up cron jobs to run
iostat at regular intervals and log the output to a file for later analysis. For example, adding this line to your crontab will log disk I/O every 10 minutes:
*/10 * * * * /usr/bin/iostat -x >> /var/log/iostat.log
Combine with Other Tools:
iostat is great for I/O-specific monitoring, but combining it with other tools like
top or
htop for CPU and memory monitoring, and
iotop for per-process I/O, can give you a more holistic view of system performance.
https://www.howtoforge.com/how-to-install-and-use-iostat-on-debian-12/?__cf_chl_tk=TmGeD6lGBQ8oDTcuZId5Ih83DwVRDOxtH6Jvm2b0lrQ-1725066004-0.0.1.1-4991
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10973950/viewspace-3026475/ ,如需转载,请注明出处,否则将追究法律责任。