Linux下的一些I/O统计工具-2

上一篇 / 下一篇  2012-08-29 09:44:19 / 个人分类:Linux

51Testing软件测试网Wk+qwXUUx7ZC3i

  iopp

*b#a&i?Q(m9?7}051Testing软件测试网_ F;e/~&J!Y

  iopp是另外一个统计每一个进程I/O的工具,使用C语言编写,理论上应该比上述两个重狙效率都要高。51Testing软件测试网GTq+bC/E3J

51Testing软件测试网"k%{0BAHP

  安装方法很简单,首先通过下面的指令下载源代码:

#@W0@v*|qJ)S0

c-mXz%nKZ0  git://github.com/markwkm/iopp.git

,Pi*g5i&W"e4qj Wi0

^(B$l(QU0w6^V0  然后分别通过下面的指令编译安装51Testing软件测试网(@a"m!gW/K/k*B$Y$L3t

51Testing软件测试网/j ?&cQdH

51Testing软件测试网&d TJ5rE%HRJLP1D

  1. cmake CMakeLists.txt  
  2. make  
  3. make install DESTDIR=/usr

I4@+D%D^F$Emu0  下面是一个使用例子51Testing软件测试网7fwZ5@W [Z

51Testing软件测试网X)pi\*Yo)UjG?

n`U@b.V0
  1. iopp -i -c 2  
  2.   pid    rchar    wchar    syscr    syscw   rbytes   wbytes  cwbytes command  
  3.  2144        0      296       40        8        0        0        0 /usr/sbin/LCDd  
  4.  2284        0        0        2        0        0        0        0 ha_logd: read process  
  5.  2299        0        0        2        0        0        0        0 ha_logd: write process  
  6.  2520        3        3        3        3        0        0        0 /usr/lib/virtualbox/vboxwebsrv  
  7.  2599        2        2        2        2        0        0        0 /usr/lib/virtualbox/VBoxSVC  
  8.  2675        0        0        1        0        0        0        0 runsvdir  
  9.  3177       16       16        4        2        0        0        0 /usr/bin/gnome-shell  
  10.  3192       16       16        4        2        0        0        0 nautilus  
  11.  3305      180      340      100       60        0        0        0 /usr/lib/icedove/icedove-bin  
  12.  3623     1393     1440        1        1        0        0        0 sshd: wgzhao@pts/0  
  13.  4305        0  4603904        0      562        0  4603904        0 postgres: writer process     
  14.  6257  2064384  1892352      252      215  3719168   139264        0 postgres: wgzhao pgbench [local] UPDATE

"q)u7}C:US{g"x0  上述输出的各项含义是:

ed5?~ Aj6I.@c l$F0

M.B K Kp?S0  ● pid 进程ID51Testing软件测试网'}WZXmY+WPh0_

51Testing软件测试网yOs2Z/{

  ● rchar 将要从磁盘读取的字节数

6i6g'@~4xE5uO051Testing软件测试网:Kg]-x'JO9N%d,X#M

  ● wchar 已经写入或应该要写入磁盘的字节数51Testing软件测试网J Y2l|!F

3@1S9[tk-^ T;o0  ● syscr 读I/O数

tZu%x;X2u${lU051Testing软件测试网c:R4yi&v

  ● syscw 写I/O数51Testing软件测试网uo6H!b j;V,]#P3n E

Q:@~(r_iV0  ● rbytes 真正从磁盘读取的字节数

j iPo(f7Hi n051Testing软件测试网}V(u(J2Nz5Q7qg)W j

  ● wbytes 真正写入到磁盘的字节数

_ M |~]:r2|7`0

X4T9rD&P4R,x0  ● cwbytes 因为清空页面缓存而导致没有发生操作的字节数

2U%~ ~'Er"lo Jj@"K051Testing软件测试网 na-AiR+Z xT6gl }j

  ● command 执行的命令

S&K.eQ a*N,~0

c u0k[*pG5|0  其中rbytes,wbytes,cwbytes会因给出-k或者-m参数,而显示为rkb,wkb,cwkb或rmb,wmb,cwmb。command一列如果给出-c的参数则显示完整的命令名而不仅仅只是命令本身。51Testing软件测试网%Q'P1_c!ME{yZ

51Testing软件测试网"e@u6p.VlQ

  这些参数的使用和top类似。51Testing软件测试网h"p6DH?v u)@

/U'yY&W-V+?u:my0  更具体的可以参考iopp(8)手册。51Testing软件测试网qV7T(|eN+W


tA"VG TB6|m6V~0

A0B(F+~Hv0  dstat

wn'_ N/k w|0

U+~@X0w6?vT3n0  dstat 号称各种资源统计工具,其目的是想替代vmstat,iostat,netstat,ifstat等各种单一统计工具,从而做到All in one。 dstat用Python语言编写。51Testing软件测试网*yX6Re7XUS

+C+Cl*w\Ro0  dstat能够清晰显示每列的信息,特别是单位及大小很明确,不会在单位换算上犯迷糊和失误。最重要的是,因为它是基于模块化设计,因此我们可以很容易的写一个插件来收集我们需要的统计信息。51Testing软件测试网@$mnm{w k1?a

51Testing软件测试网 c Xk5xe8\ OI

  另外,dstat的输出还可以导出为CSV格式文件,从而可以在电子表格工具里分方便的生成统计图形。51Testing软件测试网9Va sw+s"K

51Testing软件测试网5W at@ S!} w[0m

  目前dstat的插件已经相当多了,这是我机器上目前的输出:51Testing软件测试网7vYoji,]i0CA;m

51Testing软件测试网(Z%O;VtMue

`hA~*} I9@e}0
  1. $ dstat  --list  
  2. internal:  
  3.   aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net,   
  4.   page, page24, proc, raw, socket, swap, swapold, sys, tcp, time, udp, unix, vm  
  5. /usr/share/dstat:  
  6.   battery, battery-remain, cpufreq, dbus, disk-tps, disk-util, dstat, dstat-cpu, dstat-ctxt,   
  7.   dstat-mem, fan, freespace, gpfs, gpfs-ops, helloworld, innodb-buffer, innodb-io, innodb-ops, lustre,   
  8.   memcache-hits, mysql-io, mysql-keys, mysql5-cmds, mysql5-io, mysql5-keys, net-packets, nfs3,   
  9.   nfs3-ops, nfsd3, nfsd3-ops, ntp, postfix, power, proc-count, qmail, rpc, rpcd, sendmail, snooze,   
  10.   squid, test, thermal, top-bio, top-bio-adv, top-childwait, top-cpu, top-cpu-adv, top-cputime,   
  11.   top-cputime-avg, top-int, top-io, top-io-adv, top-latency, top-latency-avg, top-mem, top-oom, utmp,   
  12.   vm-memctl, vmk-hba, vmk-int, vmk-nic, vz-cpu, vz-io, vz-ubc, wifi

B2yH%BU"f W!S0  下面给出几个使用的列子(实际输出是带彩色的,很容易识别)51Testing软件测试网%K,LaJr?` ?X

51Testing软件测试网0_)m aX(XVxC

  dstat的缺省输出

8P0t*z vF.hr9\051Testing软件测试网%i8u;yE$n7X fEh+v

4N@o W`[k)Ir0
  1. wgzhao-nb:~# dstat  
  2. You did not select any stats, using -cdngy by default.  
  3. ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--  
  4. usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw   
  5.   2   1  87  10   0   0| 816k  385k|   0     0 |   0     0 |2279  7048   
  6.   5   1  78  16   0   0|2600k    0 | 140B  940B|   0     0 |5952    13k  
  7.   5   3  80  12   0   0|2896k  182k|  70B  358B|   0     0 |6074    14k  
  8.   4   2  78  16   0   0|2724k    0 |  70B  374B|   0     0 |5703    15k  
  9.   4   2  81  14   0   0|3008k    0 |  70B  358B|   0     0 |5924    13k  
  10.   5   1  80  14   0   0|1976k   17k|  70B  358B|   0     0 |5819    13k  
  11.   5   2  79  14   0   0|2056k    0 | 198B  374B|   0     0 |5618    13k  
  12.   4   2  79  15   0   0|2416k    0 |  70B  358B|   0     0 |5866    15k  
  13.   5   2  78  15   0   0|2528k    0 |  70B  358B|   0     0 |6356    14k  
  14.   5   2  78  16   0   0|2288k    0 |  70B  358B|   0     0 |6515    15k  
  15.   5   2  79  14   0   0|2656k 8192B|  70B  358B|   0     0 |6490    15k  
  16.   3   2  81  13   0   0|2296k    0 |  70B  374B|   0     0 |5573    15k  
  17.   4   3  76  17   0   1|2224k    0 |  70B  358B|   0     0 |5366    12k  
  18.   5   1  81  13   0   0|2208k    0 | 508B  358B|   0     0 |5403    13k  
  19.   4   2  79  15   0   0|2024k  182k|  70B  358B|   0     0 |5583    13k  
  20.   5   2  79  15   0   0|2148k   17k| 186B  490B|   0     0 |5400    12k
51Testing软件测试网tp J? yM"p!c
51Testing软件测试网9T.rd YOt

  指定需要显示的列

r\6O a:kwi#I]A051Testing软件测试网7D ay/N#JTMY

51Testing软件测试网#X2^)J`:pk4P Z

  1. wgzhao-nb:~# dstat  -c --top-cpu -d --top-bio --top-latency  
  2. Module dstat_top_latency failed to load. (Kernel has no scheduler statistics, use at least 2.6.12)  
  3. ----total-cpu-usage---- -most-expensive- -dsk/total- ----most-expensive----  
  4. usr sys idl wai hiq siq|  cpu process   | read  writ|  block i/o process     
  5.   2   1  87  10   0   0|gnome-shell  0.7| 826k  384k|postgres    692k   52k  
  6.   4   2  79  16   0   0|postgres: wgz3.0|1744k  776k|postgres: w1744k   72k  
  7.   5   3  78  15   0   0|postgres: wgz5.0|3120k    0 |postgres: w3064k  136k  
  8.   6   2  73  19   0   0|postgres: wgz4.2|2608k  285k|postgres: w2608k  136k  
  9.   4   2  77  17   0   0|postgres: wgz3.5|2112k  848k|postgres: w2112k   88k  
  10.   3   2  71  25   0   0|postgres: wgz2.0| 944k 1049k|postgres: w 936k   48k  
  11.   3   2  58  37   0   0|postgres: wgz2.0| 920k 2070k|postgres: w 928k   64k  
  12.   3   2  62  34   0   0|postgres: wgz2.2|1496k  992k|postgres: w1608k   72k  
  13.   3   2  56  38   0   0|postgres: wgz3.0|1840k  645k|postgres: w1856k   88k  
  14.   3   2  78  17   0   0|postgres: wgz3.0|1420k 1200k|postgres: w1292k   80k  
  15.   5   2  80  12   0   1|postgres: wgz4.2|2628k    0 |postgres: w2636k  112k  
  16.   4   3  69  25   0   0|postgres: wgz3.8|2168k  576k|postgres: w2224k  104k

+V X1nu3cP0  指定需要显示的列,并同时将结果导出到文件

9k'wDR.f+e_6T051Testing软件测试网2}D$xiy_Zk

&Rt WUgX7]p%v0
  1. wgzhao-nb:~# dstat  --disk --mem --proc --io --sys --filesystem --tcp --vm --output dstat.csv  
  2. -dsk/total- ------memory-usage----- ---procs--- --io/total- ---system-- --filesystem- ----tcp-sockets---- -----virtual-memory----  
  3.  read  writ| used  buff  cach  free|run blk new| read  writ| int   csw |files  inodes|lis act syn tim clo|majpf minpf alloc  free  
  4.  844k  404k| 829M 19.4M 2920M  124M|  0 0.0 0.7|47.5  38.4 |2336  7185 | 4928  12286 | 11   3   0   0   2|   1   620   602   605   
  5. 2128k 1526k| 828M 19.4M 2915M  130M|  0 2.0   0| 111   157 |4588    14k| 4928  12285 | 11   3   0   0   2|   0  1859   995  2278   
  6.  920k 2151k| 826M 19.4M 2917M  129M|  0 2.0   0|52.0   237 |3091  7540 | 4928  12284 | 11   3   0   0   2|   0  4448  2330  2144   
  7. 2124k 1003k| 826M 19.4M 2921M  126M|1.0 1.0   0| 135   106 |4705    14k| 4928  12284 | 11   3   0   0   2|   0   331   865     1   
  8. 2344k 1024k| 826M 19.4M 2924M  122M|1.0 2.0   0| 121   118 |4074    13k| 4928  12284 | 11   3   0   0   2|   0   249   953     1   
  9. 1572k 1624k| 827M 19.4M 2926M  120M|1.0 2.0   0|87.0   190 |3231    11k| 4928  12284 | 11   3   0   0   2|   0    98   530     1   
  10.  916k  788k| 827M 19.4M 2928M  119M|  0 2.0   0|68.0  92.0 |3452  8709 | 4928  12284 | 11   3   0   0   2|   0   128   383     4   
  11. 2452k 1665k| 826M 19.4M 2931M  116M|1.0 1.0   0| 132   197 |4779    14k| 4928  12284 | 11   3   0   0   2|   0   208   822     1   
  12. 1552k 1328k| 827M 19.4M 2933M  114M|  0 2.0   0|97.0   156 |3762  9117 | 4928  12284 | 11   3   0   0   2|   0   133   473     1   
  13. 1192k 2024k| 827M 19.4M 2934M  112M|  0 2.0   0|81.0   239 |4068    11k| 4928  12284 | 11   3   0   0   2|   0   135   414     2   
  14. 2668k  584k| 827M 19.4M 2937M  109M|  0 2.0   0| 148  71.0 |4415    10k| 4928  12284 | 11   3   0   0   2|   0   174   870     4   
  15. 1712k  960k| 827M 19.4M 2940M  106M|  0 2.0   0| 122   113 |4454    14k| 4928  12284 | 11   3   0   0   2|   0   182   616     2

p Z|B,j0  更详细的用法,可以参考dstat(1)手册。51Testing软件测试网f8LqjiQ8\T i


TAG:

 

评分:0

我来说两句

Open Toolbar