はじめに
サーバが重いなーとか負荷とか調べたいときはuptime、topから始まり
vmstat、iostataなんか見るわけですがdstatが良いらしいので入れて使ってみるテスト
dstat特徴
入れる
rpm
# cd /usr/local/src # sudo wget http://apt.sw.be/redhat/el5/en/x86_64/extras/RPMS/dstat-0.7.2-1.el5.rfx.noarch.rpm # sudo rpm -ihv dstat-0.7.2-1.el5.rfx.noarch.rpm # which dstat /usr/bin/dstat
オプションめんどいのでエイリアス追加
自分用だけにこっそり入れたかったので/home/hoge.zshrcに記述します
エイリアス追加
# vi /home/hoge.zshr --viで追記-- if [ -x /usr/bin/dstat ]; then alias dstat-full='dstat -tclmdrn' alias dstat-mem='dstat -tclm' alias dstat-cpu='dstat -tclr' alias dstat-net='dstat -tclnd' alias dstat-disk='dstat -tcldr' fi ------------
※tは時間表示ですが、T(大文字)にすることでepochになります
その他
出力結果をファイル保存
-
- outputオプションで結果をcsv保存できる
# dstat-full --output /home/hoge/dstat_`date "+%Y-%m-%d"`.csv # cat /home/hoge/dstat_2014-01-21.csv "Dstat 0.7.2 CSV output" "Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/" "Host:","hoge.co.jp",,,,"User:","hoge" "Cmdline:","dstat -tclmdrn --output /home/hoge/dstat_2014-01-21.csv",,,,"Date:","21 Jan 2014 13:39:34 JST" "system","total cpu usage",,,,,,"load avg",,,"memory usage",,,,"dsk/total",,"io/total",,"net/total", "time","usr","sys","idl","wai","hiq","siq","1m","5m","15m","used","buff","cach","free","read","writ","read","writ","recv","send" 21-01 13:39:34,0.418,0.625,98.378,0.556,0.006,0.018,0.0,0.010,0.0,527532032.0,432185344.0,836317184.0,172974080.0,919.306,13619.905,0.074,1.231,0.0,0.0 21-01 13:39:35,0.0,1.0,99.0,0.0,0.0,0.0,0.0,0.010,0.0,527781888.0,432185344.0,836321280.0,172720128.0,0.0,0.0,0.0,0.0,8316.0,1665.0