Мониторинг дискового ввода-вывода: `iostat`, `iotop`
Отслеживайте и анализируйте производительность дискового ввода-вывода, чтобы выявлять узкие места.
«Мониторинг дискового ввода-вывода: `iostat`, `iotop`» — бесплатный урок Linux Command Line Mastery на CoddyKit. Это урок 1 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Linux Command Line Mastery, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Linux Command Line Mastery содержит 4 уроков всего.
Части этого урока еще не переведены и отображаются на английском.
Why Monitor Disk I/O?
Disk Input/Output (I/O) refers to the data moving between your computer's CPU and its storage devices (like hard drives or SSDs).
Monitoring disk I/O is crucial for understanding system performance. Slow disk I/O can be a major bottleneck, making your applications and overall system feel sluggish, even if your CPU and memory are underutilized.
Introducing `iostat`
The iostat command is part of the sysstat package and is used to report CPU statistics and device I/O statistics.
It provides a system-wide view of disk activity, helping you identify if your storage devices are struggling to keep up with demand.
Running iostat without any options gives you a snapshot of current I/O performance.
iostatDecoding Basic `iostat` Output
A typical iostat output shows several key metrics:
Device: The name of the storage device (e.g.,sda,nvme0n1).tps: Transfers per second (read + write).kB_read/s: Kilobytes read from the device per second.kB_wrtn/s: Kilobytes written to the device per second.kB_read: Total kilobytes read since boot.kB_wrtn: Total kilobytes written since boot.
These give you a quick overview of the overall data flow.
Advanced `iostat` Metrics
For deeper insights, use iostat -x to see extended statistics. Pay attention to:
r/s,w/s: Reads/writes per second (similar totps, but separated).rkB/s,wkB/s: Read/write kilobytes per second.%util: Percentage of time the device was busy. High%util(near 100%) indicates a potential bottleneck.await: The average time (in milliseconds) for I/O requests issued to the device to be served. This includes time spent in queue and service time.
High await values suggest I/O requests are waiting too long.
iostat -xReal-time Monitoring with `iostat`
To observe I/O activity over time, you can specify an interval in seconds. This allows you to see how stats change during different workloads.
For example, iostat -d 2 3 will display disk statistics every 2 seconds, for a total of 3 reports. The -d flag limits the output to only disk statistics.
iostat -d 2 3Focusing on Specific Disks
If you have multiple storage devices, you might want to monitor a specific one. You can append the device name to the iostat command.
For instance, to monitor the sda device with extended statistics every 5 seconds, you would use iostat -x 5 sda.
This helps pinpoint issues on individual drives.
iostat -x 5 sdaIntroducing `iotop`
While iostat provides system-wide disk I/O statistics, iotop gives you a more granular, process-level view.
iotop shows which processes are actively performing disk I/O, similar to how top shows CPU usage per process. This is invaluable for identifying specific applications or services hogging disk resources.
iotopUnderstanding `iotop` Output
When you run iotop, you'll see a real-time list of processes and their I/O activity. Key columns include:
TID/PID: Thread or Process ID.USER: The user owning the process.DISK READ: Current disk read rate of the process.DISK WRITE: Current disk write rate of the process.SWAPIN: Percentage of time spent swapping.IO%: Total I/O percentage for the process.
By default, it sorts by IO%, making it easy to spot I/O-intensive tasks.
Identifying I/O Hogs with `iotop`
iotop is interactive by default, but you can use flags for specific views. For example, iotop -oPa shows only processes with active I/O, aggregated for each process, and non-interactive.
This helps quickly identify which processes are causing high disk activity and potentially impacting overall system performance.
iotop -oPaCheck Your I/O Knowledge
Which iostat metric directly indicates the percentage of time a storage device is busy processing requests?
I/O Monitoring Recap
In this lesson, you've learned how to use two powerful Linux commands for disk I/O monitoring:
iostat: Provides system-wide disk I/O statistics, including transfers per second, read/write rates, and crucial metrics like%util(device utilization) andawait(request latency). It's great for identifying overall disk bottlenecks.iotop: Offers a real-time, process-level view of disk I/O, helping you pinpoint specific applications or services that are consuming significant disk resources.
Mastering these tools is essential for diagnosing and resolving performance issues related to storage.
Часто задаваемые вопросы
Урок «Мониторинг дискового ввода-вывода: `iostat`, `iotop`» бесплатный?
Да — полный текст урока «Мониторинг дискового ввода-вывода: `iostat`, `iotop`» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Linux Command Line Mastery, подпишись на CoddyKit PRO. Курс Linux Command Line Mastery содержит 4 уроков всего.
Чему я научусь в уроке «Мониторинг дискового ввода-вывода: `iostat`, `iotop`»?
Отслеживайте и анализируйте производительность дискового ввода-вывода, чтобы выявлять узкие места. Ты практикуешь Linux Command Line Mastery с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать Linux Command Line Mastery?
Предыдущий опыт не требуется. Linux Command Line Mastery на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 1 из 4.
Сколько времени занимает урок «Мониторинг дискового ввода-вывода: `iostat`, `iotop`»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке Linux Command Line Mastery?
Да. Каждый урок Linux Command Line Mastery включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Мониторинг дискового ввода-вывода: `iostat`, `iotop`
- Инструменты анализа производительности памяти и CPU
- Расширенное журналирование и методы устранения неполадок
- Трассировка системных вызовов с strace и ltrace