Dstat 是一個多樣化的資源統計工具。
官網上是這麼說的,感覺一下:java
Dstat is a versatile replacement for vmstat, iostat, netstat and ifstat. Dstat overcomes some of their limitations and adds some extra features, more counters and flexibility. Dstat is handy for monitoring systems during performance tuning tests, benchmarks or troubleshooting.
Dstat allows you to view all of your system resources in real-time, you can eg. compare disk utilization in combination with interrupts from your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).
dstat將以列表的形式爲你提供選項信息並清晰地告訴你是在何種幅度和單位顯示輸出。這樣更好地避免了信息混亂和誤報。更重要的是,它可讓你更容易編寫插件來收集你想要的數據信息,以從未有過的方式進行擴展。python
Dstat的默認輸出是專門爲人們實時查看而設計的,不過你也能夠將詳細信息經過CSV輸出到一個文件,並導入到Gnumeric或者Excel生成表格中。mysql
以上的特色是從官網扒下來的,能夠參考一下。ios
centos 能夠直接使用以下命令安裝:redis
yum install dstat
[root@pandora ~]# dstat --list internal: aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net, page, page24, proc, raw, socket, swap, swapold, sys, tcp, time, udp, unix, vm /usr/share/dstat: battery, battery-remain, cpufreq, dbus, disk-util, fan, freespace, gpfs, gpfs-ops, helloworld, innodb-buffer, innodb-io, innodb-ops, lustre, memcache-hits, mysql-io, mysql-keys, mysql5-cmds, mysql5-conn, mysql5-io, mysql5-keys, net-packets, nfs3, nfs3-ops, nfsd3, nfsd3-ops, ntp, postfix, power, proc-count, rpc, rpcd, sendmail, snooze, thermal, top-bio, top-cpu, top-cputime, top-cputime-avg, top-io, top-latency, top-latency-avg, top-mem, top-oom, utmp, vm-memctl, vmk-hba, vmk-int, vmk-nic, vz-cpu, vz-io, vz-ubc, wifi
經過dstat --list
能夠查看 dstat 能使用的全部參數,其中上面 internal 是 dstat 自己自帶的一些監控參數,下面 /usr/share/dstat
中是 dstat 的插件,這些插件能夠擴展 dstat 的功能,如能夠監控電源(battery)、mysql等。
下面這些插件並非均可以直接使用的,有的還依賴其餘包,如想監控 mysql,必需要裝 python 鏈接 mysql 的一些包。sql
用法能夠用 -h
選項看下,或者 man dstat
查一下。我執行了一下,大概是這樣的:centos
[root@pandora ~]# dstat -h 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 --bw, --blackonwhite change colors for white background terminal --float force float values on screen --integer force integer values on screen --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)
直接執行 dstat
這個命令,默認選項是 -cdngy
,1s 顯示一條信息。能夠在最後指定顯示一條信息的時間間隔,如dstat 5
是每 5s 顯示一條,dstat 5 10
表示每 5s 顯示一條,一共顯示 10 條。網絡
一個可能的輸出以下:ssh
[root@pandora ~]# dstat ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- usr sys idl wai hiq siq| read writ| recv send| in out | int csw 3 4 92 0 0 0| 135k 4182k| 0 0 | 52k 86k| 20k 50k 4 3 93 0 0 0| 0 3668k|5873B 5436B| 0 120k| 30k 51k 4 3 93 0 0 0| 0 3632k|6040B 4520B| 0 100k| 32k 55k 4 3 93 0 0 0|4096B 3832k|3274B 1574B| 0 72k| 30k 50k 4 3 93 0 0 0| 0 3644k|3404B 1654B| 0 120k| 33k 57k
能夠看到的統計項有如下幾個:-c
選項。CPU 狀態:從左到右依次是用戶/系統/空閒部分的 cpu 佔比,wait,硬/軟中斷次數。-d
選項。磁盤狀態:磁盤的讀寫操做,這一欄顯示磁盤的讀、寫總數。-n
選項。網絡狀態:網絡設備發送和接受的數據。-g
選項。頁面狀態:系統的分頁活動,分頁指的是一種內存管理技術用於查找系統場景,一個較大的分頁代表系統正在使用大量的交換空間,或者說內存很是分散,大多數狀況下你都但願看到 page in(換入)和 page out(換出)的值是 0。-y
選項。系通通計:中斷(int)和上下文切換(csw)數量。較高的值一般表示大量的進程形成擁塞,須要對 CPU 進行關注。socket
--socket
顯示經常使用的 socket 統計--tcp
顯示經常使用的TCP統計--mem
顯示內存使用率--io
顯示I/O統計--int
顯示終端統計
--disk-util
顯示某一時間磁盤的忙碌情況--freespace
顯示當前磁盤空間使用率--proc-count
顯示正在運行的程序數量--top-bio
指出塊I/O最大的進程--top-cpu
圖形化顯示CPU佔用最大的進程--top-io
顯示正常I/O最大的進程--top-mem
顯示佔用最多內存的進程
一個可能的輸出以下:
[root@pandora ~]# dstat --tcp --io --top-cpu --top-io --mem --top-mem ----tcp-sockets---- --io/total- -most-expensive- ----most-expensive---- ------memory-usage----- --most-expensive- lis act syn tim clo| read writ| cpu process | i/o process | used buff cach free| memory process 12 29 0 0 0|4.93 46.2 |codis-config 0.0|sshd 102k 46k|38.7G 333M 60.4G 152G|java 183M 12 29 0 0 0| 0 27.0 |irqbalance 0.0|irqbalance 48k 0 |38.7G 333M 60.4G 152G|java 183M 12 29 0 0 0| 0 4.00 |codis-config 0.0|redis-serve 34k 47B|38.7G 333M 60.4G 152G|java 183M 12 29 0 0 0| 0 1.00 |bin/codis-con0.0|redis-serve 34k 54B|38.7G 333M 60.3G 152G|java 183M