dstat 使用例

estis2014/06/14 (土) 11:21 に投稿
# dstat -t --top-cpu-adv --top-io-adv 3 2
----system---- -------most-expensive-cpu-process------- -------most-expensive-i/o-process-------
     time     |process              pid  cpu read write|process              pid  read write cpu
14-06 11:07:20|httpd                134260.0%   0    0 |init                 1    1011B 234B0.0%
14-06 11:07:23|httpd                134230.2%   0    0 |sshd: estis@pts/0    7857  322B 363B  0%
14-06 11:07:26|                                        |sshd: estis@pts/0    7857  205B 245B  0%

引数 3 は、delay, 結果表示の間隔、単位は秒。デフォルトは、1秒。
引数 2 は、count, 回数。デフォルトは無限。
--noupdate を指定しない場合、途中経過を表示する。(delayが2秒以上の場合)

--output FILENAME で、CSV形式で出力結果が、FILENAMEファイルに保存される。

# dstat -ta --output=tmp 1 2
----system---- ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
     time     |usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
14-06 11:15:16|  0   0 100   0   0   0|  34B  593B|   0     0 |   0     0 |  43    57 
14-06 11:15:17|  0   0  99   0   0   0|   0     0 | 204B  934B|   0     0 |  59    56 
14-06 11:15:18|  1   0 100   0   0   0|   0     0 | 108B  390B|   0     0 |  57    57 

# cat tmp
"Dstat 0.7.2 CSV output"
"Author:","Dag Wieers ",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","localhost.localdomain",,,,"User:","root"
"Cmdline:","dstat -ta --output=tmp 1 2",,,,"Date:","14 Jun 2014 11:15:16 JST"

"system","total cpu usage",,,,,,"dsk/total",,"net/total",,"paging",,"system",
"time","usr","sys","idl","wai","hiq","siq","read","writ","recv","send","in","out","int","csw"
14-06 11:15:16,0.057,0.098,99.576,0.270,0.000,0.000,33.589,593.262,0.0,0.0,0.0,0.0,42.587,57.478
14-06 11:15:17,0.498,0.498,99.005,0.0,0.0,0.0,0.0,0.0,204.0,934.0,0.0,0.0,59.0,56.0
14-06 11:15:18,0.500,0.0,99.500,0.0,0.0,0.0,0.0,0.0,108.0,390.0,0.0,0.0,57.0,57.0

しかし、top-io-adv プラグイン使用時はエラーになる。
バグらしい。

# dstat -t --top-io-adv --output=tmp 1 2
Traceback (most recent call last):
  File "/usr/bin/dstat", line 2554, in 
    main()
  File "/usr/bin/dstat", line 2416, in main
    scheduler.run()
  File "/usr/lib/python2.6/sched.py", line 117, in run
    action(*argument)
  File "/usr/bin/dstat", line 2514, in perform
    oline = oline + o.showcsv() + o.showcsvend(totlist, vislist)
  File "/usr/share/dstat/dstat_top_io_adv.py", line 75, in showcsv
    return self.val['i/o process'] + 'Top: %s\t%s\t%s\t%s' % (self.val['name'][0:self.width-20], self.val['read_usage'], self.val['write_usage'], self.val['cpu_usage'])
KeyError: 'i/o process'