`
paladin1988
  • 浏览: 319828 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

【转】PROC文件系统重要数据—cpu、disk、memory、load、net

阅读更多

 

来源:http://cjhust.blog.163.com/blog/static/175827157201172002431722/

 

1#cat /proc/diskstats

监控内容:每块磁盘设备的IO统计信息列表

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力
参数解析—中文版(共11个域)

1个域:读磁盘的次数,成功完成读的总次数;

2个域:合并读次数;

3个域:读扇区的次数,成功读过的扇区总次数;

4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数;//基准

5个域:写完成的次数,成功写完成的总次数;

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

7个域:写扇区的次数,成功写扇区总次数;

8个域:写花费的毫秒数,这是所有写操作所花费的毫秒数;//基准

9个域:I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小;

10个域:花在I/O操作上的毫秒数,这个域会增长只要field 9不为0

11个域:加权,花在I/O操作上的毫秒数,在每次I/O开始,I/O结束,I/O合并时这个域都会增加。这可以给I/O完成时间和存储那些可以累积的提供一个便利的测量标准。

参数解析—英文版(共11个域)

Field 1: number of issued reads. This is the total number of reads completed successfully.读次数

Field 2: number of reads merged

Field 3: number of sectors read. This is the total number of sectors read successfully.

Field 4: 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()).

Field 5: number of writes completed. This is the total number of writes completed successfully.

Field 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.

Field 7: number of sectors written. This is the total number of sectors written successfully.

Field 8: 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()).

Field 9: 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.   //IO的当前进度,应该为0

Field 10: number of milliseconds spent doing I/Os. This field is increased so long as field 9 is nonzero.

Field 11: 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.

参照iostat

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力

 

1rrqm/s:   每秒进行 merge 的读操作数目,即 delta(rmerge)/s

//对应/proc/diskstats的第2个域(合并读次数)


2
wrqm/s: 每秒进行 merge 的写操作数目,即 delta(wmerge)/s

//对应/proc/diskstat的第6个域(合并写次数)


3
r/s:  每秒完成的读 I/O 设备次数,即 delta(rio)/s

//对应/proc/diskstat的第1个域(读磁盘次数)
4
w/s: 每秒完成的写 I/O 设备次数,即 delta(wio)/s

//对应/proc/diskstat的第5个域(写磁盘次数)


5
rsec/s:  每秒读扇区数,即 delta(rsect)/s

//对应/proc/diskstat的第3个域(读扇区次数)


6
wsec/s: 每秒写扇区数,即 delta(wsect)/s

//对应/proc/diskstat的第7个域(写扇区次数)


7
rkB/s: 每秒读K字节数。是 rsect/s 的一半,因为每扇区大小为512字节。(需要计算)
8
wkB/s:   每秒写K字节数。是 wsect/s 的一半。(需要计算)
9
avgrq-sz: 平均每次设备I/O操作的数据大小 (扇区)delta(rsect+wsect)/delta(rio+wio)
10
avgqu-sz: 平均I/O队列长度。即 delta(aveq)/s/1000 (因为aveq的单位为毫秒)
11
await:  平均每次设备I/O操作的等待时间 (毫秒)。即 delta(ruse+wuse)/delta(rio+wio)
12
svctm:  平均每次设备I/O操作的服务时间 (毫秒)。即 delta(use)/delta(rio+wio)
13
%util:  一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的。即 delta(use)/s/1000 (因为use的单位为毫秒)

备注:iostat的数据主要参考了/proc/partions /proc/diskstats /proc/cpuinfo等信息,因此我们需读取/proc/partions /proc/diskstats里的数据,并对数据进行匹配和记录。

2#cat /proc/loadavg

监控内容:CPU和磁盘I/O的负载平均值

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力
参数解析

10.33表示:1分钟平均负载;
2
0.33表示:5分钟平均负载;
3
0.28表示:15分钟平均负载;
4
1/64表示:分子是内核正在运行的进程数,分母是存在系统中的进程总数;

519059表示:最近运行的进程ID

3#cat /proc/meminfo

监控内容:内存使用情况
PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力
参数解析:系统中关于当前内存的利用状况等的信息

MemTotal: 1028548 kB 

//所有可用RAM大小(即物理内存减去一些预留位和内核的二进制代码大小);

 

 

MemFree: 96040 kB

//LowFreeHighFree的总和;

 

 

Buffers: 67012 kB

//用来给块设备做的缓冲大小(只记录文件系统的metadata以及 tracking in-flight pages,就是说 buffers是用来存储,目录里面有什么内容,权限等等);

 

 

Cached:         438456 kB

//用来给文件做缓冲大小(直接用来记忆我们打开的文件),它不包括SwapCached

 

 

SwapCached:          0 kB

//已经被交换出来的内存,但仍然被存放在swapfile中,用来在需要的时候很快的被替换而不需要再次打开I/O端口;

 

 

Active:         481612 kB

//最近经常被使用的内存,除非非常必要否则不会被移作他用;

 

Inactive:       320548 kB 

//最近不经常被使用的内存,非常用可能被用于其他途径;

 

SwapTotal:     2907756 kB

//交换空间的总和;

 

SwapFree:      2907708 kB

//RAM中被替换出暂时存在磁盘上的空间大小;

 

Dirty:               0 kB

//等待被写回到磁盘的内存大小;

 

Writeback:           0 kB

//正在被写回到磁盘的内存大小;

 

AnonPages:      296864 kB

 

Mapped:          71176 kB

//影射文件的大小;

 

Slab:            89940 kB

//内核数据结构缓存;

 

SReclaimable:    68768 kB

SUnreclaim:      21172 kB

PageTables:      23064 kB

NFS_Unstable:        0 kB

Bounce:              0 kB

CommitLimit:   3422028 kB

Committed_AS:   681012 kB

 

VmallocTotal: 34359738367 kB  

 //vmalloc内存大小;

 

VmallocUsed:      8224 kB    

 //已经被使用的虚拟内存大小;

 

VmallocChunk: 34359729643 kB

//已经被使用的虚拟内存大小;

 

HugePages_Total:     0

HugePages_Free:      0

HugePages_Rsvd:      0

Hugepagesize:     2048 kB

参照freevmstat
PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力

4#cat /proc/stat

监控内容:实时追踪自系统上次启动以来的多种统计信息

cpu  53015 18703 106630 19380972 49615 287 1123 0

cpu0 26759 8928 55545 9673506 37564 28 751 0

cpu1 26255 9775 51084 9707466 12050 258 371 0

intr 447772        //自系统启动以来,发生的中断数

ctxt 14983019      //自系统启动以来,CPU发生的上下文交换的次数

btime 1304847387  //从系统启动到现在为止的时间

processes 233676   //系统启动以来所创建的任务的个数目

procs_running 1    //当前运行队列的任务的数目

procs_blocked 0    //当前被阻塞的任务的数目

参数解析

实时追踪自系统上次启动以来的多种统计信息, “cpu”行后的八个值分别表示以0.01jiffies)秒为单位的统计值(包括系统运行于用户模式、低优先级用户模式,运系统模式、空闲模式、I/O等待模式的时间等):
1
53015(user)从系统启动开始累计到当前时刻,用户态的CPU时间(单位:jiffies),不包含 nice值为负进程;
218703(nice)从系统启动累计到当前时刻,nice值为负的进程所占用的CPU时间;
3106630(system) 从系统启动开始累计到当前时刻,核心时间;
419380972(idle)从系统启动开始累计到当前时刻,除硬盘IO等待时间以外其它等待时间;
549615(iowait)从系统启动开始累计到当前时刻,硬盘IO等待时间;
6287(irq)从系统启动开始累计到当前时刻,硬中断时间;
71123(softirq)从系统启动开始累计到当前时刻,软中断时间 

CPU时间 = user + system + nice + idle + iowait + irq + softirq

 8“intr”给出中断的信息,第一个为自系统启动以来,发生的所有的中断的次数;然后每个数对应一个特定的中断自系统启动以来所发生的次数; 
 9
“ctxt”给出了自系统启动以来CPU发生的上下文交换的次数。 
 10
“btime”给出了从系统启动到现在为止的时间,单位为秒; 
 11
“processes (total_forks)自系统启动以来所创建的任务的个数目; 
 12
“procs_running”当前运行队列的任务的数目; 
 13
“procs_blocked”当前被阻塞的任务的数目;

 

补充内容

主要功能:查看CPU利用率

基本原理:CPU利用率分为用户态(CPU处于用户态执行的时间A)、系统态(系统内核执行的时间B)和空闲态(空闲系统进程执行的时间C),CPU利用率=CPU执行非系统空闲进程的时间 / CPU总的执行时间=A+B/A+B+C

公式换算:

cpu usage = (idle2-idle1)/(cpu2-cpu1)*100
cpu usage = [(user_2 +sys_2+nice_2) - (user_1 + sys_1+nice_1)]/(total_2 - total_1)*100

5#cat /proc/net/dev

监控内容:网络信息

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力
参数解析

1)接收或传输的字节;
2
)接收或传输的压缩字节;< xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" />

3)收到或传输的误码数;
4
)收到或传输的漏失误码;
5
)收到或传输的FIFO误码;
6
)收到或传输的帧误码;
7
)收到或传输的多播误码;
8
)收到或传输的总包数;

 

6#cat /proc/vmstat
监控内容:查看虚拟内存信息

pgpgin 1709065< xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" />

pgpgout 158343643

pswpin 0

pswpout 0

pgalloc_high 68753276

pgalloc_normal 76876684

pgalloc_dma 0

pgfree 146197837

pgactivate 3907810

pgdeactivate 0

pgfault 238406978

pgmajfault 3085

 

参数解析—英文版

1pgpgin/sTotal number of kilobytes the system paged in from disk per second.

//每秒从磁盘page in的总页数(以千为单位)

 

2pgpgout/sTotal number of kilobytes the system paged out to disk per second.

//每秒从磁盘page out的总页数(以千为单位)

 

3fault/sNumber of page faults (major + minor) made by the system per second (post 2.5 kernels only).  This is not a count of page faults that  generate I/O, because some page faults can be resolved without I/O.

 

4majflt/sNumber of major faults the system has made per second, those which have required loading a memory page from disk (post 2.5 kernels only).

 

5pswpin/sTotal number of swap pages the  system  brought  in  per  second.

//每秒交换进来的内存页总数

 

6pswpout/sTotal  number  of  swap pages the system brought out per second.

//每秒交换出去的内存页总数

 

7cswch/sTotal number of context switches per second.

//系统切换情况

参照sar

/var/log/sa/sar*/var/log/sa/sa文件有关

 

sar –B
PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力

 

sar –w
PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力

 

sar –W

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力

7statfs()

监控内容:磁盘空间使用情况
参数解析

struct statfs {

      long    f_type;     /* type of filesystem (see below) */

      long    f_bsize;    /* optimal transfer block size */

      long    f_blocks;   /* total data blocks in file system */

      long    f_bfree;    /* free blocks in fs */

      long    f_bavail;   /* free blocks avail to non-superuser */

      long    f_files;     /* total file nodes in file system */

      long    f_ffree;    /* free file nodes in fs */

      fsid_t   f_fsid;      /* file system id */

      long    f_namelen;  /* maximum length of filenames */

};

df –i

//-i选项:显示i节点信息,而不是磁盘块;

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力
df –P

//-P选项:use the POSIX out format结果和df命令显示的内容一样;

 

PROC文件系统重要数据—cpu、disk、memory、load、net - cjhust - 我一直在努力

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics