dstat的使用

本文摘自:http://blog.csdn.net/chen_jp/article/details/8966054

1. 下載&安裝

ContosRedhat的下載鏈接:http://pkgs.repoforge.org/dstat/

20130523163740773


安裝很簡單,如下:


20130523163836224

2. 使用說明

安裝完後就可以使用了,dstat非常強大,可以實時的監控cpu、磁盤、網絡、IO、內存等使用情況。

直接使用dstat,默認使用的是-cdngy參數,分別顯示cpudisknetpagesystem信息,默認是1s顯示一條信息。可以在最後指定顯示一條信息的時間間隔,如dstat 5是沒5s顯示一條,dstat 5 10表示沒5s顯示一條,一共顯示10條。


20130523164005675

下面對顯示出來的部分信息作一些說明:

1. cpuhiqsiq分別爲硬中斷和軟中斷次數。

2. systemintcsw分別爲系統的中斷次數(interrupt)和上下文切換(context switch

其他的都很好理解。

通過dstat --help可以看到常用參數選項

[root@localhost ~]# dstat --help

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

Versatile tool for generating system resource statistics


Dstat options:

 -c, --cpu              enable cpu stats

    -C 0,3,total           include cpu0, cpu3 and total

 -d, --disk             enable disk stats

    -D total,hda           include hda and total

 -g, --page             enable page stats

 -i, --int              enable interrupt stats

    -I 5,eth2              include int5 and interrupt used by eth2

 -l, --load             enable load stats

 -m, --mem              enable memory stats

 -n, --net              enable network stats

    -N eth1,total          include eth1 and total

 -p, --proc             enable process stats

 -r, --io               enable io stats (I/O requests completed)

 -s, --swap             enable swap stats

    -S swap1,total         include swap1 and total

 -t, --time             enable time/date output

 -T, --epoch            enable time counter (seconds since epoch)

 -y, --sys              enable system stats


 --aio                  enable aio stats

 --fs, --filesystem     enable fs stats

 --ipc                  enable ipc stats

 --lock                 enable lock stats

 --raw                  enable raw stats

 --socket               enable socket stats

 --tcp                  enable tcp stats

 --udp                  enable udp stats

 --unix                 enable unix stats

 --vm                   enable vm stats


 --plugin-name          enable plugins by plugin name (see manual)

 --list                 list all available plugins


 -a, --all              equals -cdngy (default)

 -f, --full             automatically expand -C, -D, -I, -N and -S lists

 -v, --vmstat           equals -pmgdsc -D total


 --float                force float values on screen

 --integer              force integer values on screen


 --bw, --blackonwhite   change colors for white background terminal

 --nocolor              disable colors (implies --noupdate)

 --noheaders            disable repetitive headers

 --noupdate             disable intermediate updates

 --output file          write CSV output to file


delay is the delay in seconds between each update (default: 1)

count is the number of updates to display before exiting (default: unlimited)


[root@localhost ~]#

如想監控swapprocesssocketsfilesystem並顯示監控的時間

20130523164103566

若要將結果輸出到文件可以加--output filename


20130523164141984

這樣生成的csv文件可以用excel打開,然後生成圖表。

通過dstat --list可以查看dstat能使用的所有參數,其中上面internaldstat本身自帶的一些監控參數,下面/usr/share/dstat中是dstat的插件,這些插件可以擴展dstat的功能,如可以監控電源(battery)、mysql等。

下面這些插件並不是都可以直接使用的,有的還依賴其他包,如想監控mysql,必須要裝python連接mysql的一些包。


20130523164226907

如我們可以看下當前最消耗IO的進程和最消耗塊設備IO的進程可以執行如下命令:

20130523164303466

這裏使用了dstat的插件,更多功能有待進一步挖掘。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章