如何监控磁盘活动?

Fri*_*sen 87 performance monitoring hard-drive

如何在 Ubuntu 上查看我的磁盘活动?例如,如何监控正在从磁盘写入和读取的内容以及磁盘使用率?

我正在寻找类似于 Windows 中的资源监视器的应用程序。

mch*_*hid 89

您可以使用iotop。要安装,请打开终端并执行以下命令:

sudo apt-get install iotop
Run Code Online (Sandbox Code Playgroud)

要使用 iotop,请打开终端并键入以下命令:

sudo iotop
Run Code Online (Sandbox Code Playgroud)

iotop 具有实时显示所有磁盘活动的功能,还可以像资源监视器一样显示负责活动的命令和命令背后的用户。

点击这里查看更多信息。

在此处输入图片说明

与资源监视器类似的还有 htop,它具有识别和终止进程的能力:

sudo apt-get install htop
Run Code Online (Sandbox Code Playgroud)

并在监控模式下运行 htop:

htop
Run Code Online (Sandbox Code Playgroud)

或者,要获得更多功能和权限以完全调试和终止单个进程等:

sudo htop
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

  • 您要求的是磁盘活动,而不是磁盘使用情况。这是您问题的完美答案。 (8认同)
  • 太难了,我只需要一个值 - 0-100% DISK Usage... (2认同)

Red*_*yed 67

您可以使用htop

sudo apt install htop
Run Code Online (Sandbox Code Playgroud)

然后打开htop并进行配置: F2->列->设置IO_RATE(或IO_RATE_READ/IO_RATE_WRITE)->F10

你会看到这样的事情:

截屏

  • 这应该是问题的答案! (8认同)
  • 极好的。这是正确的答案。 (3认同)
  • 当您在 setup 中选择 `IO_RATE` 列时会出现 `DISK R/W`。`IO_RATE` 是每秒字节数的总 I/O(读取和写入)。 (2认同)

Ram*_*and 27

你可以试试nmon

sudo apt-get install nmon
Run Code Online (Sandbox Code Playgroud)

尝试:

nmon
Run Code Online (Sandbox Code Playgroud)

输出如下:

在此处输入图片说明

Press d = Disk | Press c = CPU Info |Press r = RAM info | Press q = to exit
Run Code Online (Sandbox Code Playgroud)


Anw*_*war 13

您可以使用dstat程序。要安装它,只需在终端中执行命令

sudo apt-get install dstat
Run Code Online (Sandbox Code Playgroud)

使用该dstat命令,您将获得一个完整的实时 CPU/网络/磁盘-活动监控视图,如下所示

mas@mas-laptop:~ > dstat 
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
 15   5  76   4   0   0| 181k  177k|   0     0 |   0    61B|1651  3609 
  5   0  95   0   0   0|   0     0 | 162B 1064B|   0     0 | 500   994 
 15   4  77   4   0   0|   0   292k| 302B   52B|   0     0 | 687  1919 
  6   1  92   1   0   0|   0     0 |   0     0 |   0     0 | 496  1089 
  5   1  94   1   0   1|   0     0 |   0     0 |   0     0 | 422   919
  6   1  93   1   0   0|   0     0 |   0     0 |   0     0 | 517  1181 
  9   2  89   1   0   1|   0     0 |   0     0 |   0     0 | 494  1066
Run Code Online (Sandbox Code Playgroud)

要仅获取最近 15 分钟内负载指示器的磁盘使用信息,请使用dstat --disk --fs --load命令。下面给出了一个示例输出

$ dstat --disk --fs

-dsk/total- --filesystem- ---load-avg---
 read  writ|files  inodes| 1m   5m  15m 
 895k  186k|13728    100k|0.63 0.73 0.84
   0     0 |13728    100k|0.63 0.73 0.84
   0     0 |13728    100k|0.63 0.73 0.84
   0     0 |13728    100k|0.63 0.73 0.84
   0    12k|13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84^C
Run Code Online (Sandbox Code Playgroud)

dstat --help 有这些信息:

Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics

Dstat options:
  -c, --cpu              enable cpu stats
     -C 0,3,total           include cpu0, cpu3 and total
  -d, --disk             enable disk stats
     -D total,hda           include hda and total
  -g, --page             enable page stats
  -i, --int              enable interrupt stats
     -I 5,eth2              include int5 and interrupt used by eth2
  -l, --load             enable load stats
  -m, --mem              enable memory stats
  -n, --net              enable network stats
     -N eth1,total          include eth1 and total
  -p, --proc             enable process stats
  -r, --io               enable io stats (I/O requests completed)
  -s, --swap             enable swap stats
     -S swap1,total         include swap1 and total
  -t, --time             enable time/date output
  -T, --epoch            enable time counter (seconds since epoch)
  -y, --sys              enable system stats

  --aio                  enable aio stats
  --fs, --filesystem     enable fs stats
  --ipc                  enable ipc stats
  --lock                 enable lock stats
  --raw                  enable raw stats
  --socket               enable socket stats
  --tcp                  enable tcp stats
  --udp                  enable udp stats
  --unix                 enable unix stats
  --vm                   enable vm stats

  --plugin-name          enable plugins by plugin name (see manual)
  --list                 list all available plugins

  -a, --all              equals -cdngy (default)
  -f, --full             automatically expand -C, -D, -I, -N and -S lists
  -v, --vmstat           equals -pmgdsc -D total

  --float                force float values on screen
  --integer              force integer values on screen

  --bw, --blackonwhite   change colors for white background terminal
  --nocolor              disable colors (implies --noupdate)
  --noheaders            disable repetitive headers
  --noupdate             disable intermediate updates
  --output file          write CSV output to file

delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)
Run Code Online (Sandbox Code Playgroud)

有关此工具的更多信息,请查看以下链接:

1) 数据统计主页

2) DiskPerformance 社区文档页面