Quantcast
Channel: Network – Benjr.tw
Viewing all articles
Browse latest Browse all 56

linux command – dstat

$
0
0

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

  • Linux 預設最古老的系統資源監控程式 – top
  • 最簡單的硬碟監測工具 – iostat
  • 透過 mpstat 來看個別的 CPU 使用率與統計 –mpstat
  • sar – CPU , Memory ,I/O (Disk, Network) 的資料都可透過這一支程式來統計

但這邊還有一隻我覺得也很不錯的工具 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 <- 顯示 CPU 0 , CPU 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 <- 顯示 sda 的個別資料

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

dstat -n -N eth0,eth1 <- 顯示 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 <- 顯示 eth0, eth1 的個別資料,並將結果儲存到文字檔.

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 來查詢.


Viewing all articles
Browse latest Browse all 56

Trending Articles


Girasoles para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Tagalog Quotes About Crush – Tagalog Love Quotes


OFW quotes : Pinoy Tagalog Quotes


Long Distance Relationship Tagalog Love Quotes


Tagalog Quotes To Move on and More Love Love Love Quotes


5 Tagalog Relationship Rules


Best Crush Tagalog Quotes And Sayings 2017


Re:Mutton Pies (lleechef)


FORECLOSURE OF REAL ESTATE MORTGAGE


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Patama Quotes : Tagalog Inspirational Quotes


Pamatay na Banat and Mga Patama Love Quotes


Tagalog Long Distance Relationship Love Quotes


BARKADA TAGALOG QUOTES


“BAHAY KUBO HUGOT”


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.