linux command – dstat

Loading

一般 Linux 文字介面下常用的系統資源監控有

但這邊還有一隻我覺得也很不錯的工具 dstat 它提供更多元的設定方式來顯示要監控的 CPU , Memory ,I/O (Disk, Network) 資料.

root@ubuntu:~# dstat
The program 'dstat' is currently not installed. You can install it by typing:
apt-get install dstat

不過 Ubuntu 不是預設的套件,直接透過 apt-get 就找得到.

root@ubuntu:~# apt-get install dstat
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dstat
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 68.2 kB of archives.
After this operation, 351 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/universe dstat all 0.7.2-3build1 [68.2 kB]
Fetched 68.2 kB in 8s (8,076 B/s)
Selecting previously unselected package dstat.
(Reading database ... 195097 files and directories currently installed.)
Preparing to unpack .../dstat_0.7.2-3build1_all.deb ...
Unpacking dstat (0.7.2-3build1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up dstat (0.7.2-3build1) ...

安裝完之後就可以執行 dstat ,這也是最簡單的監控 CPU , Disk , Network , Memory , System 的統計資料.

root@ubuntu:~# 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   1  98   0   0   0| 123k   28k|   0     0 | 137B  760B|  68   147 
  1   1  99   0   0   0| 256k    0 | 720B  360B|   0     0 | 113   350 

一般可以監控的裝置,簡稱 cdngy paramater 他們實際代表如下:

  • c : cpu stats (total cpu usage)
  • d : disk stats (disk/total)
  • n : network stats (net/total)
  • g : page stats (paging)
  • y : system stats (system)

但以上的參數會顯示系統所有的統計資料,如 CPU 會顯示所有 CPU 的統計資料,不過我們還是可以透過參數指定個別 CPU 的統計資料.
dstat -c -C 0,1

root@ubuntu:~# dstat -c -C 0,1
-------cpu0-usage--------------cpu1-usage------
usr sys idl wai hiq siq:usr sys idl wai hiq siq
  1   1  98   0   0   0:  1   1  98   0   0   0
  2   5  92   0   0   1: 16  68  10   5   0   0
  6   5  88   0   0   0: 16  44  16  20   0   3

dstat -d -D sda

root@ubuntu:~# dstat -d -D sda 
--dsk/sda--
 read  writ
  83k   20k
   0     0 
   0     0 

dstat -n -N eth0,eth1

root@ubuntu:~# dstat -n -N eth0,eth1 
--net/eth0----net/eth1-
 recv  send: recv  send
   0     0 :   0     0 
 120B  120B:   0     0 
   0     0 :   0     0 

dstat -n -N eth0,eth1 –output /tmp/output.csv

root@ubuntu:~# dstat -n -N eth0,eth1 --output /tmp/output.csv
--net/eth0----net/eth1-
 recv  send: recv  send
   0     0 :   0     0 
 180B  180B:   0     0 
 120B  120B:   0     0 
 120B  120B:   0     0 
 275B  215B:   0     0 ^C

同時會產生 /tmp/output.csv 檔案,內容和剛剛顯示類似.

root@ubuntu:~# cat /tmp/output.csv 
"Dstat 0.7.2 CSV output"
"Author:","Dag Wieers <dag@wieers.com>",,,,"URL:","http://dag.wieers.com/home-made/dstat/"
"Host:","ubuntu",,,,"User:","root"
"Cmdline:","dstat -n -N eth0,eth1 --output /tmp/output.csv",,,,"Date:","12 Jan 2015 00:43:13 PST"

"net/eth0",,"net/eth1",
"recv","send","recv","send"
0.0,0.0,0.0,0.0
180.0,180.0,0.0,0.0
120.0,120.0,0.0,0.0
120.0,120.0,0.0,0.0
275.0,215.0,0.0,0.0

dstat 的參數不只有這些,我們可以透過 #man dstat 或是 http://linux.die.net/man/1/dstat 來查詢.

更多關於硬體監控程式請參考 – https://benjr.tw/94592

沒有解決問題,試試搜尋本站其他內容

2 thoughts on “linux command – dstat

  1. 自動引用通知: nmon | Benjr.tw

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料