共计 2916 个字符,预计需要花费 8 分钟才能阅读完成。
导读 | 今天来说说 /proc/diskstats 文件,这个文件用于显示磁盘、分区和统计信息 |
[root@VM_54_118_centos ~]# cat /proc/diskstats
253 0 vda 222026 464 14148933 2387763 15975930 14162283 261012993 54210046 0 3186549 56602267
253 1 vda1 221980 464 14145765 2387590 15807400 14162283 261012993 54192784 0 3173037 56597649
253 16 vdb 1946 1 1330738 4704 332744 328392 9197624 303420 0 98203 308117
11 0 sr0 122 0 2012 92 0 0 0 0 0 91 92
7 0 loop0 0 0 0 0 0 0 0 0 0 0 0
(提前说明:由于我的测试主机是云主机,所以磁盘的格式是 vdX, 如果是本地磁盘显示的应该是 sdX)
vda 为整个虚拟磁盘的统计信息,vda1 为第一个分区的统计信息;
上面这串字符从左往右依次表示:
253:主设备号,不同类别设备编号不一样,虚拟磁盘统一为 253,磁盘统一为 8,环回设备统一为 7
1:次设备号, 比如 vda 的 vda 为 0,vda1 位 1,vda2 为 2. 也就是一个物理磁盘后面的分区,编号依次递增
vda:设备名。一般 ide 接口的以 hd[a-d] 口命名,scsi 和 sata 接口的以 sd[a-z] 命名。
输出信息说明:
/proc/diskstats 文件比 /sys/block/sda/stat 文件多 3 个域,从左至右分别对应主设备号,次设备号和设备名称。后续的 11 个域在这两个文件里是相同的,它们的函义将在下面解释。除了第 9 个域,所有的域都是从启动时的累积值。
[root@VM_54_118_centos ~]# cat /sys/block/vda/stat
222026 464 14148933 2387763 15979071 14164711 261058873 54244380 0 3187473 56636601
下面是后面的 11 个域的输出解释
第 1 个域:读完成次数 —– 读磁盘的次数,成功完成读的总次数。
(number of issued reads. This is the total number of reads completed successfully.)
第 2 个域:合并读完成次数,第 6 个域:合并写完成次数。为了效率可能会合并相邻的读和写。从而两次 4K 的读在它最终被处理到磁盘上之前可能会变成一次 8K 的读,才被计数(和排队),因此只有一次 I / O 操作。这个域使你知道这样的操作有多频繁。
(number of reads merged)
第 3 个域:读扇区的次数,成功读过的扇区总次数。
(number of sectors read. This is the total number of sectors read successfully.)
第 4 个域:读花费的毫秒数,这是所有读操作所花费的毫秒数(用__make_request() 到 end_that_request_last() 测量)。
(number of milliseconds spent reading. This is the total number of milliseconds spent by all reads (as measured from __make_request() to end_that_request_last()).)
第 5 个域:写完成次数 —- 写完成的次数,成功写完成的总次数。
(number of writes completed. This is the total number of writes completed successfully.)
第 6 个域:合并写完成次数 —–合并写次数。
(number of writes merged Reads and writes which are adjacent to each other may be merged for efficiency. Thus two 4K reads may become one 8K read before it is ultimately handed to the disk, and so it will be counted (and queued) as only one I/O. This field lets you know how often this was done.)
第 7 个域:写扇区次数 —- 写扇区的次数,成功写扇区总次数。
(number of sectors written. This is the total number of sectors written successfully.)
第 8 个域:写操作花费的毫秒数 — 写花费的毫秒数,这是所有写操作所花费的毫秒数(用__make_request() 到 end_that_request_last() 测量)。
(number of milliseconds spent writing This is the total number of milliseconds spent by all writes (as measured from __make_request() to end_that_request_last()).)
第 9 个域:正在处理的输入 / 输出请求数 — -I/ O 的当前进度,只有这个域应该是 0。当请求被交给适当的 request_queue_t 时增加和请求完成时减小。
(number of I/Os currently in progress. The only field that should go to zero. Incremented as requests are given to appropriate request_queue_t and decremented as they finish.)
第 10 个域:输入 / 输出操作花费的毫秒数 —- 花在 I / O 操作上的毫秒数,这个域会增长只要 field 9 不为 0。
(number of milliseconds spent doing I/Os. This field is increased so long as field 9 is nonzero.)
第 11 个域:输入 / 输出操作花费的加权毫秒数 —– 加权,花在 I / O 操作上的毫秒数,在每次 I / O 开始,I/ O 结束,I/ O 合并时这个域都会增加。这可以给 I / O 完成时间和存储那些可以累积的提供一个便利的测量标准。
(number of milliseconds spent doing I/Os. This field is incremented at each I/O start, I/O completion, I/O merge, or read of these stats by the number of I/Os in progress (field 9) times the number of milliseconds spent doing I/O since the last update of this field. This can provide an easy measure of both I/O completion time and the backlog that may be accumulating.)
正文完
星哥说事-微信公众号
![post-qrcode](https://www.xgss.net/wp-content/uploads/2023/07/二维码-微信公众号256x256.jpg)