linux文件/proc/diskstats注解

如果不用命令查看某些系统状态,比如需要自己编写python等脚本的时候,就要用到各种的系统文件,这里注解磁盘信息文件/proc/diskstats。

[root@node1 proc]# cat diskstats 
  11       0 sr0 18 0 2056 383 0 0 0 0 0 376 383
   8       0 sda 8821 34 484957 208310 1062 175 37797 252131 0 89700 460277
   8       1 sda1 2194 0 50096 41631 10 0 4137 31 0 38002 41642
   8       2 sda2 6596 34 432757 166586 1052 175 33660 252100 0 55376 418542
   8      16 sdb 325 0 6662 2621 33 4 672 8216 0 3507 10837
   8      32 sdc 170 0 3184 3720 0 0 0 0 0 3630 3720
 253       0 dm-0 6587 0 431099 166500 1264 0 34332 326232 0 55676 492732
 253       1 dm-1 99 0 4496 375 0 0 0 0 0 369 375
 253       2 dm-2 48 0 2112 2168 0 0 0 0 0 2093 2168

/proc/diskstats文件比/sys/block/sda/stat文件多3个域,从左至右分别对应主设备号,次设备号和设备名称。后续的11个域在这两个文件里是相同的,它们的函义将在下面解释。除了第9个域,所有的域都是从启动时的累积值。

第4个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数。

(number of issued reads. This is the total number of reads completed successfully.)

第5个域:合并读完成次数, 第6个域:合并写完成次数。为了效率可能会合并相邻的读和写。从而两次4K的读在它最终被处理到磁盘上之前可能会变成一次8K的读,才被计数(和排队),因此只有一次I/O操作。这个域使你知道这样的操作有多频繁。

(number of reads merged)

第6个域:读扇区的次数,成功读过的扇区总次数。

(number of sectors read. This is the total number of sectors read successfully.)

第7个域:读花费的毫秒数,这是所有读操作所花费的毫秒数(用__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()).)

第8个域:写完成次数 ----写完成的次数,成功写完成的总次数。

(number of writes completed. This is the total number of writes completed successfully.)

第9个域:合并写完成次数 -----合并写次数。

(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.)

第10个域:写扇区次数 ---- 写扇区的次数,成功写扇区总次数。

(number of sectors written. This is the total number of sectors written successfully.)

第11个域:写操作花费的毫秒数 — 写花费的毫秒数,这是所有写操作所花费的毫秒数(用__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()).)

第12个域:正在处理的输入/输出请求数 – -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.)

第13个域:输入/输出操作花费的毫秒数 ----花在I/O操作上的毫秒数,这个域会增长只要field 9不为0。

(number of milliseconds spent doing I/Os. This field is increased so long as field 9 is nonzero.)

第14个域:输入/输出操作花费的加权毫秒数 ----- 加权, 花在I/O操作上的毫秒数,在每次I/O开始,I/O结束,I/O合并时这个域都会增加。这可以给I/O完成时间和存储那些可以累积的提供一个便利的测量标准。
  
总结来说,14个域对应以下含义
设备号 编号 设备 读完成次数 合并完成次数 读扇区次数 读操作花费毫秒数 写完成次数 合并写完成次数 写扇区次数 写操作花费的毫秒数 正在处理的输入/输出请求数 输入/输出操作花费的毫秒数 输入/输出操作花费的加权毫秒数。
除正在处理的输入/输出请求数这项是非累积值外,其他磁盘统计都是累积值。

zabbix中磁盘使用情况就是从diskstats采集,磁盘使用率计算方式为:

两次采集的输入/输出操作花费的毫秒数之差 / 采集间隔时间

例如:第一次采集输入/输出操作花费的毫秒数为90258834,间隔10秒后采集的值为90258710

那么磁盘使用率为 (90258710ms - 90258834ms)/ 10*1000ms = 0.0124,也就是1.24%

猜你喜欢

转载自blog.csdn.net/cyan_grey/article/details/82787686