[linux] /proc/diskstats各列含义介绍以及磁盘使用率计算方式说明

摘要:
320人读取存储在Linux系统/proc目录中并以文件形式保存的当前系统操作的所有状态信息,例如CPU信息文件cpuinfo、内存信息文件meminfo和磁盘信息文件diskstats。Ramdisk设备是一种通过软件将RAM用作硬盘的技术。user_00@xxxxxx64:~˃cat/sys/block/sda/stat30537200910873031947611542194510267776181116405048712264801809410887302116/proc/diskstats文件比/sys/block/sda/stat文件多3个字段,从左到右分别对应主设备号、辅助设备号和设备名。第四个字段:读取所用的毫秒数。这是所有读取操作花费的毫秒数。第五个字段:写入完成数----写入完成数,成功写入完成总数。
320人阅读
 

Linux系统/proc目录下存放着当前系统运行的各项状态信息,以文件形式保存,例如CPU信息文件cpuinfo,内存信息文件meminfo,磁盘信息文件diskstats。

其中diskstats中每一列的含义对照如下:

1 0 sda  505235  28461  7421219  6259625  2397331 3804539  49818500  25885599  0  6122393 32152888

设备号 编号 设备  读完成次数  合并完成次数   读扇区次数   读操作花费毫秒数   写完成次数   合并写完成次数   写扇区次数   写操作花费的毫秒数   正在处理的输入/输出请求数   输入/输出操作花费的毫秒数   输入/输出操作花费的加权毫秒数。

除正在处理的输入/输出请求数这项是非累积值外,其他磁盘统计都是累积值。

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

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

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

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

user_00@xxxxxx64:~> cat /proc/diskstats
   1    0 ram0 0 0 0 0 0 0 0 0 0 0 0
   1    1 ram1 0 0 0 0 0 0 0 0 0 0 0
   1    2 ram2 0 0 0 0 0 0 0 0 0 0 0
   1    3 ram3 0 0 0 0 0 0 0 0 0 0 0
   1    4 ram4 0 0 0 0 0 0 0 0 0 0 0
   1    5 ram5 0 0 0 0 0 0 0 0 0 0 0
   1    6 ram6 0 0 0 0 0 0 0 0 0 0 0
   1    7 ram7 0 0 0 0 0 0 0 0 0 0 0
   1    8 ram8 0 0 0 0 0 0 0 0 0 0 0
   1    9 ram9 0 0 0 0 0 0 0 0 0 0 0
   1   10 ram10 0 0 0 0 0 0 0 0 0 0 0
   1   11 ram11 0 0 0 0 0 0 0 0 0 0 0
   1   12 ram12 0 0 0 0 0 0 0 0 0 0 0
   1   13 ram13 0 0 0 0 0 0 0 0 0 0 0
   1   14 ram14 0 0 0 0 0 0 0 0 0 0 0
   1   15 ram15 0 0 0 0 0 0 0 0 0 0 0
   7    0 loop0 0 0 0 0 0 0 0 0 0 0 0
   7    1 loop1 0 0 0 0 0 0 0 0 0 0 0
   7    2 loop2 0 0 0 0 0 0 0 0 0 0 0
   7    3 loop3 0 0 0 0 0 0 0 0 0 0 0
   7    4 loop4 0 0 0 0 0 0 0 0 0 0 0
   7    5 loop5 0 0 0 0 0 0 0 0 0 0 0
   7    6 loop6 0 0 0 0 0 0 0 0 0 0 0
   7    7 loop7 0 0 0 0 0 0 0 0 0 0 0
   8    0 sda 30526 2009 1087215 193416 115412736 102258023 1811485376 87116184 0 18093240 87295592
   8    1 sda1 22754 483028 5686677 45493256
   8    2 sda2 166 662 8265 66120
   8    3 sda3 6528 570989 123499806 987893792
   8    4 sda4 2887 30896 88516083 708124240

   9    0 md0 0 0 0 0 0 0 0 0 0 0 0

这个命令用于显示磁盘、分区和统计信息:sda为整个硬盘的统计信息,sda1为第一个分区的统计信息,sda2为第二个分区的统计信息。

ramdisk设备为通过软件将RAM当做硬盘来使用的一项技术。

user_00@xxxxxx64:~> cat  /sys/block/sda/stat

30537     2009  1087303   193476 115421945 102267776 1811640504 87122648        0 18094108 87302116

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

   

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

免责声明:文章转载自《[linux] /proc/diskstats各列含义介绍以及磁盘使用率计算方式说明》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇单词 统计ABP 动态 WebApi 隐藏接口的方法(一)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

C#中精确计时的一点收获

以下所有代码运行环境:Windows 2003, Intel(R) Core(TM) 2 Duo CPU E8400@ 3.00GHz 2.99GHz,2.96GB内存 根据综合网上的一些文章,精确计时主要有以下几种方式 1 调用WIN API中的GetTickCount [DllImport("kernel32")] static extern uin...

new Date 时间赋值方式

原文地址:http://www.likecs.com/show-55086.html 处理时间是常见的需求,总结下Date类的相关知识 构建时间对象 Date对象基于1970年1月1日(世界标准时间)起的毫秒数。 构建对象实例有多种方式: 不传入参数,默认以系统当前时间返回一个时间对象.new Date(); new Date(); //...

Date对象

原文地址:https://wangdoc.com/javascript/ 普通函数的用法 Date对象可以作为普通函数直接调用,返回一个代表当前时间的字符串,即使带有参数Date作为普通函数使用时,返回的还是当前时间。 Date() // "Wed Dec 05 2018 17:12:15 GMT+0800 (中国标准时间)" Date(2000, 1,...

Linux获取系统当前时间(精确到毫秒)

#include <stdio.h> #include <time.h> #include <sys/time.h> void sysLocalTime() { time_t timesec;...

java 获取两个日期相差的毫秒数

       方法一可以使用date的getTime()方法来将当前日期格式的时间转换为毫秒数,进而相减。         long systime = new Date().getTime();//当前系统时间        long oldtime = old.getTime();//相比较的时间        Long time = (systime...

JavaScript中的Date类型计算时间差

接触JavaScript不久,今日想写一个简单的秒表练练手,于是就想当然的写下了如下代码: vardate =new Date(currTime.getTime() - beginTime.getTime()); // currTime.getTime()=1329655993149 beginTime.getTime()=1329655991421 v...