如何监控特定设备或挂载点的读写速度

如何监控特定设备或挂载点的读写速度

如何监控 Linux 中特定设备或挂载点的读写速度,例如/dev/sdc2挂载到哪个/mnt/data/

例如,希望以 MB/s 为单位显示速度,并每秒更新一次或两次。

答案1

iostat是您的事实来源,特别是iostat -md /dev/devicename 1对于您的用例。

-m Display statistics in megabytes per second.

-z Tell iostat to omit output for any devices for which there was no activity during the sample period.

root@kahnbox:/home/kahn$ iostat -md /dev/sda 1
Linux 5.4.17-100.fc30.x86_64 (kahnbox)  31/07/20        _x86_64_        (4 CPU)

Device             tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda               4.61         0.00         0.12       2521     152976

Device             tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda               3.00         0.00         0.04          0          0

Device             tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda               0.00         0.00         0.00          0          0

tps: Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Multiple logical requests can be combined into a single I/O request to the device. A transfer is of indeterminate size.

我更喜欢-z旗帜,因为它会减少喋喋不休。通过在命令末尾包含1,只要可以提供结果,您每秒都会获得结果。

如果您想安装此实用程序,则需要获取该sysstat软件包:

root@kahnbox:/home/kahn$ yum whatprovides iostat                                                                                                                                                                                                                                                                             
Last metadata expiration check: 1:32:20 ago on Fri 31 Jul 2020 13:44:22 EDT.
sysstat-11.7.3-3.fc30.x86_64 : Collection of performance monitoring tools for Linux
Repo        : @System
Matched from:
Filename    : /usr/bin/iostat

sysstat-11.7.3-3.fc30.x86_64 : Collection of performance monitoring tools for Linux
Repo        : fedora
Matched from:
Filename    : /usr/bin/iostat

答案2

我认为这iostat是实现此目的的首选工具。例子:

iostat -d -t -p sdc 1 2

sdc该命令以1秒的间隔打印两次速度信息。

相关内容