LoginSignup
6
6

More than 5 years have passed since last update.

よく使うdstatコマンドオプション

Last updated at Posted at 2018-06-03

dstat は vmstat, iostat, netstatなんかをまとめた情報が取得可能。
時刻情報付与やCSV保存もできて便利。

使い方をほかのstat系と同じようにオプション、および間隔と回数を指定する。

Usage: dstat [-afv] [options..] [delay [count]]

今回確認のバージョン

$ dstat --version
Dstat 0.7.2

デフォルトのオプション

「-cdngy」

忘れたら。

#dstat
You did not select any stats, using -cdngy by default. ←★
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw
  1   0  98   1   0   0|  67k  456k|   0     0 |1697B 7138B|1061  1241

または

# dstat -h | grep  all |grep default
  -a, --all              equals -cdngy (default)

時刻とプロセス情報追加

dstat -tpa

# dstat -tpa
----system---- ---procs--- ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
     time     |run blk new|usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw
03-06 04:54:49|  0   0 0.3|  1   0  98   1   0   0|  66k  455k|   0     0 |1691B 7113B|1060  1241
03-06 04:54:50|  0   0   0|  1   0 100   0   0   0|   0    16k| 300B 1694B|   0     0 | 197   288

vmstatっぽいのに時刻追加

dstat -tv

vmstatで情報取りたいときにワンライナーとかシェル組まなくてもよくなる。

# dstat -tv
----system---- ---procs--- ------memory-usage----- ---paging-- -dsk/total- ---system-- ----total-cpu-usage----
     time     |run blk new| used  buff  cach  free|  in   out | read  writ| int   csw |usr sys idl wai hiq siq
03-06 04:55:19|  0   0 0.3| 242M    0  1438M 61.4M|1691B 7109B|  66k  454k|1059  1240 |  1   0  98   1   0   0
03-06 04:55:20|  0   0   0| 242M    0  1438M 61.4M|   0     0 |   0     0 |1290  1716 |  0   1  99   0   0   0
03-06 04:55:21|  0   0   0| 242M    0  1438M 61.4M|   0     0 |   0  8192B|1197  1657 |  0   0 100   0   0   0

vmstatの個別のオプション確認

# dstat -h | grep  vmstat
  -v, --vmstat           equals -pmgdsc -D total

デフォルトにプロセスとメモリとIOPSを追加

dstat -tpcdrmngy

ざっとみるときはこれ使う
pとrとmをよさげなところに追加。

# dstat -tpcdrmngy
----system---- ---procs--- ----total-cpu-usage---- -dsk/total- --io/total- ------memory-usage----- -net/total- ---paging-- ---system--
     time     |run blk new|usr sys idl wai hiq siq| read  writ| read  writ| used  buff  cach  free| recv  send|  in   out | int   csw
03-06 04:56:56|  0   0 0.3|  1   0  98   1   0   0|  66k  454k|3.42  22.9 | 243M    0  1438M 60.8M|   0     0 |1687B 7096B|1059  1240
03-06 04:56:57|  0   0   0|  0   1 100   0   0   0|   0     0 |   0     0 | 243M    0  1438M 60.7M|  60B 1478B|   0     0 | 223   301

IOのプロセス情報含む

dstat -tpcdrmngy --top-io
dstat -tpcdrmngy --top-io-adv

# dstat -tpcdrmngy --top-io 1 2
----system---- ---procs--- ----total-cpu-usage---- -dsk/total- --io/total- ------memory-usage----- -net/total- ---paging-- ---system-- ----most-expensive----
     time     |run blk new|usr sys idl wai hiq siq| read  writ| read  writ| used  buff  cach  free| recv  send|  in   out | int   csw |     i/o process
03-06 05:03:48|  0   0 0.3|  1   0  98   1   0   0|  66k  450k|3.39  22.8 | 253M    0  1443M 46.6M|   0     0 |1676B 7042B|1058  1240 |systemd      75k  113k
03-06 05:03:49|  0   0   0|  1   0  99   0   0   0|   0     0 |   0     0 | 253M    0  1443M 46.4M| 360B 2356B|   0     0 |1289  1737 |ora_dbrm_or6742B    0
03-06 05:03:50|  0   0   0|  1   1  98   0   0   0|   0     0 |   0     0 | 253M    0  1443M 46.1M| 120B  780B|   0     0 |1453  1802 |VBoxService2304B    0

# dstat -tpcdrmngy --top-io-adv 1 2
----system---- ---procs--- ----total-cpu-usage---- -dsk/total- --io/total- ------memory-usage----- -net/total- ---paging-- ---system-- -------most-expensive-i/o-process-------
     time     |run blk new|usr sys idl wai hiq siq| read  writ| read  writ| used  buff  cach  free| recv  send|  in   out | int   csw |process              pid  read write cpu
03-06 05:03:55|  0   0 0.3|  1   0  98   1   0   0|  66k  450k|3.39  22.8 | 252M    0  1443M 46.8M|   0     0 |1675B 7041B|1058  1240 |systemd              1      75k 113k0.0%
03-06 05:03:56|  0   0   0|  0   0  99   0   0   0|   0     0 |   0     0 | 253M    0  1443M 46.4M| 510B 2480B|   0     0 |1148  1485 |ora_gen1_orcl        3828 6742B   0 0.5%
03-06 05:03:57|  0   0   0|  2   1  97   0   0   0|   0    32k|   0  4.00 | 253M    0  1443M 46.1M| 120B  812B|   0     0 | 279   384 |ora_ckpt_orcl        3852   64k  32k  0%

CPUのプロセス情報含む

dstat -tpcdrmngy --top-cpu
dstat -tpcdrmngy --top-cpu-adv

# dstat -tpcdrmngy --top-cpu 1 2
----system---- ---procs--- ----total-cpu-usage---- -dsk/total- --io/total- ------memory-usage----- -net/total- ---paging-- ---system-- -most-expensive-
     time     |run blk new|usr sys idl wai hiq siq| read  writ| read  writ| used  buff  cach  free| recv  send|  in   out | int   csw |  cpu process
03-06 05:02:57|  0   0 0.3|  1   0  98   1   0   0|  66k  451k|3.40  22.8 | 249M    0  1443M 49.9M|   0     0 |1677B 7049B|1058  1240 |ora_vktm_orcl0.9
03-06 05:02:58|  0   0   0|  0   1  99   0   0   0|   0     0 |   0     0 | 249M    0  1443M 49.8M| 452B 2324B|   0     0 |1281  1687 |ora_vktm_orcl2.0
03-06 05:02:59|  0   0   0|  2   1  97   0   0   1|   0     0 |   0     0 | 249M    0  1443M 49.8M| 212B  764B|   0     0 |1293  1734 |ora_vktm_orcl1.0

# dstat -tpcdrmngy --top-cpu-adv 1 2
----system---- ---procs--- ----total-cpu-usage---- -dsk/total- --io/total- ------memory-usage----- -net/total- ---paging-- ---system-- -------most-expensive-cpu-process-------
     time     |run blk new|usr sys idl wai hiq siq| read  writ| read  writ| used  buff  cach  free| recv  send|  in   out | int   csw |process              pid  cpu read write
03-06 05:03:02|  0   0 0.3|  1   0  98   1   0   0|  66k  451k|3.40  22.8 | 249M    0  1443M 49.9M|   0     0 |1677B 7048B|1058  1240 |ora_vktm_orcl        3818 0.9%   7B   0
03-06 05:03:03|  0   0   0|  0   0 100   0   0   0|   0    32k|   0  4.00 | 250M    0  1443M 49.5M| 360B 2420B|   0     0 |1302  1716 |ora_vktm_orcl        3818 1.5%   0    0
03-06 05:03:04|  0   0   0|  2   1  97   0   0   0|   0     0 |   0     0 | 250M    0  1443M 49.3M| 270B  888B|   0     0 |1313  1735 |ora_vktm_orcl        3818 2.0%   0    0


CSVで保存

dstat -tv --output /tmp/dstat_log.csv

# dstat -tv --output /tmp/dstat_log.csv
----system---- ---procs--- ------memory-usage----- ---paging-- -dsk/total- ---system-- ----total-cpu-usage----
     time     |run blk new| used  buff  cach  free|  in   out | read  writ| int   csw |usr sys idl wai hiq siq
03-06 05:14:00|  0   0 0.3| 254M    0  1445M 42.5M|1658B 6963B|  65k  446k|1057  1239 |  1   0  98   0   0   0
03-06 05:14:01|  0   0   0| 254M    0  1445M 42.4M|   0     0 |   0     0 |1277  1771 |  1   0  99   0   0   0
03-06 05:14:02|  0   0   0| 254M    0  1445M 42.4M|   0     0 |   0    32k|1139  1716 |  0   0 100   0   0   0^C

# cat /tmp/dstat_log.csv
"Dstat 0.7.2 CSV output"
"Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","hostname",,,,"User:","root"
"Cmdline:","dstat -tv --output /tmp/dstat_log.csv",,,,"Date:","03 Jun 2018 05:14:00 UTC"

"system","procs",,,"memory usage",,,,"paging",,"dsk/total",,"system",,"total cpu usage",,,,,
"time","run","blk","new","used","buff","cach","free","in","out","read","writ","int","csw","usr","sys","idl","wai","hiq","siq"
<中略>
03-06 05:14:01,0.0,0.0,0.0,266346496.0,0.0,1515556864.0,44474368.0,0.0,0.0,0.0,0.0,1277.0,1771.0,0.518,0.0,99.482,0.0,0.0,0.0
03-06 05:14:02,0.0,0.0,0.0,266346496.0,0.0,1515556864.0,44474368.0,0.0,0.0,0.0,32768.0,1139.0,1716.0,0.0,0.0,100.0,0.0,0.0,0.0
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6