一、命令介紹
dstat是監控本機多種資源的監控工具,是vmstat, iostat and ifstat的替代工具。
RHEL6.4安裝dstat: rpm -ivh dstat-0.7.0-1.el6.noarch
二、基本使用
直接輸入dstat,會使用默認值,每秒顯示一次cpu、disk、net、paging、system的數據。等於dstat -cdngy 1。
基本用法
dstat [-afv] [options..] [delay [count]]
常用選項如下:
dstat 3 #3秒輸出一條信息
dstat -N eth0 #顯示eth0網卡進出流量
dstat -l #顯示cpu在1、5、15分鐘的負載
dstat -r #顯示io讀寫流量
有關Dstat涉及的些參數含義說明:
Dstat options:
-c, --cpu 顯示CPU情況
-C 0,3,total include cpu0, cpu3 and total
-d, --disk 顯示磁盤情況
-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 顯示內存情況
-n, --net 顯示網絡情況
-N eth1,total 可以指定網絡接口
-p, --proc enable process stats
-s, --swap 顯示swap情況
-S swap1,total 可以指定多個swap
-t, --time enable time counter
-y, --sys enable system stats
--ipc 報告IPC消息隊列和信號量的使用情況
--lock enable lock stats
--raw enable raw stats
--tcp enable tcp stats
--udp enable udp stats
--unix enable unix stats
-M stat1,stat2 enable external stats
--mods stat1,stat2
-a, --all 使用-cdngy 缺省的就是這樣顯示
-f, --full 使用 -C, -D, -I, -N and -S 顯示
-v, --vmstat 使用-pmgdsc -D 顯示
--integer show integer values
--nocolor disable colors (implies --noupdate)
--noheaders 只顯示一次表頭以後就不顯示了,使用重定向寫入文件時很有用
--noupdate disable intermediate updates
--output file 寫入到CVS文件中
三、高級用法
顯示mem、io、cpu使用最高的進程:
如下選項,可以得到佔用資源最多的進程和用戶。
--top-bio
show most expensive block I/O process
--top-cpu
show most expensive CPU process
--top-cputime
show process using the most CPU time (in ms)
--top-cputime-avg
show process with the highest average timeslice (in ms)
--top-io
show most expensive I/O process
--top-latency
show process with highest total latency (in ms)
--top-latency-avg
show process with the highest average latency (in ms)
--top-mem
show process using the most memory