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

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

8M/o6v7J I#ixb6b:v0  iopp

,Icc|!O K4k0

^#Y!q)rB6~S]0  iopp是另外一个统计每一个进程I/O的工具,使用C语言编写,理论上应该比上述两个重狙效率都要高。51Testing软件测试网 c*]4tT I}:e$?

}|"HN*@LQ0  安装方法很简单,首先通过下面的指令下载源代码:51Testing软件测试网7of,C/A zR'R-DfZ

`,]6p;J*b0W0  git://github.com/markwkm/iopp.git

A.A XLW-I L]q051Testing软件测试网 Q2R\+g;T&r'`zp

  然后分别通过下面的指令编译安装

l S V*C8p1I*wV0

i)P6_8U/WZ!d0

W(]rK4f-B6x5u4n0
  1. cmake CMakeLists.txt  
  2. make  
  3. make install DESTDIR=/usr

9B6Rq1i6og0  下面是一个使用例子51Testing软件测试网v#~6de}#m)XF-n s7s

51Testing软件测试网S$V\/XQ3@:GpJ Mb

51Testing软件测试网9?)~t(n"~1D Qe6^

  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

;Z-k JA+c[0  上述输出的各项含义是:

$F y A9~S zu7i6{9`051Testing软件测试网 tBDn9dAV)K)WO

  ● pid 进程ID51Testing软件测试网3X'd.}Zy r:Qy'L

51Testing软件测试网 _[i\i9T/N)Up1Ir

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

7L ptRH/JA0

WeNYY"C0  ● wchar 已经写入或应该要写入磁盘的字节数51Testing软件测试网5cP? @QoDI

51Testing软件测试网0lDO;[K{

  ● syscr 读I/O数51Testing软件测试网\7}9I E+L.x+Af~

51Testing软件测试网 X,k7A6U ObEM |

  ● syscw 写I/O数51Testing软件测试网D,h9b,o IN.z)F

O/s%uN(qQ9r0  ● rbytes 真正从磁盘读取的字节数51Testing软件测试网Qv l+x3x*O'XJ+P$R r

g K \} r9B0  ● wbytes 真正写入到磁盘的字节数

%Q }8sHK:`^,|)m [0

?p D"T,py3MUz0  ● cwbytes 因为清空页面缓存而导致没有发生操作的字节数

]`#H O7w2R051Testing软件测试网/j/N5K~]

  ● command 执行的命令

?6bN/f{051Testing软件测试网;iCi*n k lD1b2Z%L

  其中rbytes,wbytes,cwbytes会因给出-k或者-m参数,而显示为rkb,wkb,cwkb或rmb,wmb,cwmb。command一列如果给出-c的参数则显示完整的命令名而不仅仅只是命令本身。

o f?-n1?JTyG[V6s051Testing软件测试网xO{,XS

  这些参数的使用和top类似。

M/dc\&k*h7Q0

#B3y,D3l"v3vJ"Z5p$UG0  更具体的可以参考iopp(8)手册。

9b Or\X)oS[G0
b1K mB,T0

3`/o2T T`)?M4}&R0  dstat

YH5{"`i#I`"FT"tk051Testing软件测试网6up0h"L@e#]0KZ+z

  dstat 号称各种资源统计工具,其目的是想替代vmstat,iostat,netstat,ifstat等各种单一统计工具,从而做到All in one。 dstat用Python语言编写。51Testing软件测试网D|;w)jM

51Testing软件测试网q4Z7r/G-dWp6e(}

  dstat能够清晰显示每列的信息,特别是单位及大小很明确,不会在单位换算上犯迷糊和失误。最重要的是,因为它是基于模块化设计,因此我们可以很容易的写一个插件来收集我们需要的统计信息。51Testing软件测试网(B] K_0gs W?6T

z^+d(SQV4v~0  另外,dstat的输出还可以导出为CSV格式文件,从而可以在电子表格工具里分方便的生成统计图形。51Testing软件测试网)m5b o5B:XR%Kn!r

51Testing软件测试网 U'L(A wx

  目前dstat的插件已经相当多了,这是我机器上目前的输出:51Testing软件测试网O7~ zh.C6j"[

7k*Hlq'q.Yy051Testing软件测试网4]h9b*Z]?Q

  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
51Testing软件测试网8f]&Cw};g"|l N8Nj

  下面给出几个使用的列子(实际输出是带彩色的,很容易识别)51Testing软件测试网i8E!C]2b2F!k;`\g

51Testing软件测试网d7H.c1dW(a-wV'\:U

  dstat的缺省输出51Testing软件测试网 q l?V*F4[dNX

51Testing软件测试网c_9Pgn5l+M8H@

51Testing软件测试网"wN IP$F

  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

dl d;Yj+o7t#aON0

H@ev&T$k9A0  指定需要显示的列

g&G j'p!C#j4Hs$jde051Testing软件测试网0|l ?h W e^.}od]

N)lz}_!}"_:b Z0
  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
51Testing软件测试网)wwV;Lb4E

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

F{'~*F%ql0

r#WIMj051Testing软件测试网 J;Gq.hbI@}vs

  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
51Testing软件测试网n}$S5M/W)a%fg

  更详细的用法,可以参考dstat(1)手册。

A V u}K!M z-Z0

TAG:

 

评分:0

我来说两句

Open Toolbar