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

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

)|`V!{J0  iopp

9yu`JL*o:V051Testing软件测试网 y fxkP T"Q,U;e[

  iopp是另外一个统计每一个进程I/O的工具,使用C语言编写,理论上应该比上述两个重狙效率都要高。

&y'J;^P7Yc&R051Testing软件测试网?e$Dsr0i oD

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

/r^c F)Q&Z[-I4H` K0

[M$|.X ]|4e y'q9D'?/`0  git://github.com/markwkm/iopp.git51Testing软件测试网.x{/s\.aI

&p*vb}RB/G0  然后分别通过下面的指令编译安装

2owr7}"@M6u051Testing软件测试网5D-Q2hB#U7d7dB2O}&j

51Testing软件测试网p$o"L/sY

  1. cmake CMakeLists.txt  
  2. make  
  3. make install DESTDIR=/usr
51Testing软件测试网}Es0ka [4K Z

  下面是一个使用例子

mJ3qXT0

U*Q|_7s;`j&t+u051Testing软件测试网|8KG/{4U$@Q'Ijy]

  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

1~:A"J'U-x}m-kk0  上述输出的各项含义是:

mFF3`P9Q]$w_A051Testing软件测试网dI4O!\]-u\5U

  ● pid 进程ID51Testing软件测试网Y%Y Qg+W8T&Umu'F

4wV_GS[6e0  ● rchar 将要从磁盘读取的字节数

+} T2q^&p"\,|0

)~i;z,?6N0  ● wchar 已经写入或应该要写入磁盘的字节数51Testing软件测试网P v/_rc4o,Os.{

51Testing软件测试网'\ibUN

  ● syscr 读I/O数51Testing软件测试网Y9e] {ti"e

Leq1GJ&iH0  ● syscw 写I/O数

s^ y@ p0

!]V&A4qTAK0  ● rbytes 真正从磁盘读取的字节数51Testing软件测试网+_,[!Ir|4~

.@j1KAC#^-b0  ● wbytes 真正写入到磁盘的字节数

(iQs.b6~6L051Testing软件测试网w$r9i)qo r(y+yq

  ● cwbytes 因为清空页面缓存而导致没有发生操作的字节数51Testing软件测试网^-QS*U8U&]

51Testing软件测试网 t6Qd7wn ~X2V? s

  ● command 执行的命令

%l5K$cf)n)Q9y;c0

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

;h&r\;v3}o'sA!Y051Testing软件测试网K%v V${4\&y|-W~3{2i

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

.r8AU6LHL4B'~0

|5c u!~,D!`3T0  更具体的可以参考iopp(8)手册。

B1I H [0M!]'}B051Testing软件测试网PI f6o8ST1e/|
51Testing软件测试网0} q{nk Z+b

  dstat51Testing软件测试网 B]NVXPc1\

51Testing软件测试网D+M(Ko!x0M

  dstat 号称各种资源统计工具,其目的是想替代vmstat,iostat,netstat,ifstat等各种单一统计工具,从而做到All in one。 dstat用Python语言编写。

1G4t!eg&GND0

G({3u RG:o C0  dstat能够清晰显示每列的信息,特别是单位及大小很明确,不会在单位换算上犯迷糊和失误。最重要的是,因为它是基于模块化设计,因此我们可以很容易的写一个插件来收集我们需要的统计信息。

/f/NCe"Q3u}0

'uy D9BU2h-X(}ek3h0  另外,dstat的输出还可以导出为CSV格式文件,从而可以在电子表格工具里分方便的生成统计图形。

c.cB\K-^1MA0

4g2u3R.P J0mB6l0  目前dstat的插件已经相当多了,这是我机器上目前的输出:51Testing软件测试网S[n*}V5F _

I6Z*}:]"~&V;x+~051Testing软件测试网:E(PcH1E"My%J

  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

ZZ7`r-E @9b7h0  下面给出几个使用的列子(实际输出是带彩色的,很容易识别)51Testing软件测试网1JJ*H Wp

V#Z'ox2e1A'x0  dstat的缺省输出

&izD&S$mN]9v0nw051Testing软件测试网(]3vn L3K} y

z olg!SF!R(i0
  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

7a&}LD8Jg3b9B0

:zKczXZ0  指定需要显示的列

L lvf(tzm051Testing软件测试网r,AsyIb"E3{.i

51Testing软件测试网"p"`7aTFI?

  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 Fy2}\0w v0  指定需要显示的列,并同时将结果导出到文件

Y __4W:}$k6~051Testing软件测试网*v)E8l\} zo

51Testing软件测试网4eXi4[;bSL

  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

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

P~"KI$}9w1kwp0

TAG:

 

评分:0

我来说两句

Open Toolbar