dstat †サーバの状態を見たい時にはtop、wコマンド等色々あるが、i/oやcpu、memoryを詳しく見たい時には、vmstat,iostatを使用していた。 インストール †まずはパッケージが入っているかを確認する。 # yum -y install dstat # rpm -qa | grep dstat また、このツールにはpluginも入れられるようなので更に便利になる可能性が高い。
使い方 †標準出力でdstatを叩いた場合以下の様に出力される。 # dstat --noheader --nocolor --tcp -tlmsdrnc -C 0,1,2,3 1 ----tcp-sockets---- ----system---- ---load-avg--- ------memory-usage----- ----swap--- -dsk/total- --io/total- -net/total- -------cpu0-usage------ -------cpu1-usage------ lis act syn tim clo| date/time | 1m 5m 15m | used buff cach free| used free| read writ| read writ| recv send|usr sys idl wai hiq siq:usr sys idl wai hiq siq 12 4 0 2 0|06-09 11:31:32| 0 0 0| 301M 155M 162M 378M|6776k 2041M|1164B 9829B|0.03 1.16 | 0 0 | 1 2 97 0 0 0: 0 0 100 0 0 0 12 4 0 2 0|06-09 11:31:33| 0 0 0| 301M 155M 162M 378M|6776k 2041M| 0 0 | 0 0 |1406B 1529B| 0 1 99 0 0 0: 0 0 100 0 0 0 12 4 0 2 0|06-09 11:31:34| 0 0 0| 301M 155M 162M 378M|6776k 2041M| 0 0 | 0 0 |6643B 6205B| 3 15 81 0 0 0: 0 1 99 0 0 0 オプション --noheder:ヘッダー情報を一度だけ表示する --tcp:listen, established, syn, time_wait, closeのソケット情報を出力 --nocolor:デフォルトだときれいに色づけされているが、個人的には目がチカチカして疲れるので、--nocolorで色を非表示を推奨 -tlmdrsncは複数のオプションが入っているので一つずつ見ると、 -C:cpuをコアごとにみたい場合には、-C 0,1,2という風にカンマで区切る 1:何秒ごとに取得するかを表示(2だと2秒ごと) 応用編 †csvに吐く # dstat --noheder --output dstat.csv --tcp -tlmdrnc -C 0,1,2,3 1 > /dev/null & --output dstat.csv:ファイルをcsv出力してくれる(今回のファイル名はdstat.csv) dstatの出力結果をcsvに出力させることで、後で編集しやすい。 監視用 # dstat -C 0,1,total 1 0 -CでCPUのコアを指定し、その後の引数にdelayとcountを入れる # dstat -C 0,1,total 1 0 -------cpu0-usage--------------cpu1-usage-----------total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- usr sys idl wai hiq siq:usr sys idl wai hiq siq:usr sys idl wai hiq siq| read writ| recv send| in out | int csw 0 1 99 0 0 0: 0 0 100 0 0 0: 0 0 99 0 0 0| 471B 4086B| 0 0 | 0 0 | 70 32 コアごとの使用率を出したい(idle値) # dstat -C 0,1,total 1 1 | grep -v cpu0 | grep -v usr | awk '{ print $3,$9,$15}' | awk -F'.' '{ print $1}' | awk 'NR==2' 参考 † |