一个很好的性能监测工具dstat,实在是太强大了,可以完成vmstat,iostat,netstat等等工具才能完成的任务,而且是彩色显示的,各种情况一目了然,更美妙的它可通过参数来指定显示哪些内容,如只显示CPU、内存等等,一切都可以定制,实在是方便,确实不错哦!

源码包安装:

# tar jxvf dstat-0.7.2.tar.bz2 && cd dstat-0.7.2

# make install

# cd && which dstat

   /usr/bin/dstat


   命令选项:

# dstat -h


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文件中



使用说明:

安装完成后, 执行dstat命令, 默认情况它会收集-cpu-,-disk-,-net-,-paging-,-system-的数据, 一秒钟收集一次. 默认输入dstat等于输入了dstat -cdngy 1或dstat -a 1

运行结果:
# dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq|_read _writ|_recv _send|__in_ _out_|_int_ _csw_
13  49  29   8   1   1| 424k   23k|   0     0 |   0     0 | 275   200
 0   1  95   3   0   1|8192B    0 | 297B   70B|   0     0 | 241    33
 0   1  99   0   0   0|   0     0 |  92B    0 |   0     0 | 243    14
 0   1  99   0   0   0|   0     0 | 395B    0 |   0     0 | 244    20

   很简单,一看就明白了,要说明的是如果当usr和sys的数值大于80时说明cpu的负载过重,这个软件和vmstat很像,不过和vmstat相比好像少 了io部份的显示dstat只能显示磁盘的吞吐量而不是显示负载情况,dstat和几乎所有监控软件一样,只能对整个系统进行监控而不能对某一个进程或某 一个程序进行深入分析。



常用命令:

   1.dstat -cdlmnpsy

   在1024×768的屏幕上正好全部显示出来,最好是将上面的命令设置成别名

   alias dstat='dstat -cdlmnpsy'



2.dstat -t --proc-count --top-cpu --top-mem --net-packets -lpmsa

分别显示统计时间/进程数量/占用cpu最多的进程名/占用内存最多的进程名/网络包发送量等等信息. 做个别名链接:


# alias dstat='dstat -t --proc-count --top-cpu --top-mem --net-packets -lpmsa 5'

# dstat


   3.dstat -cndymlp -N total -D total 5 25

统计CPU,IO ,network,system load


4.dstat -cdnsil -D hda -N eth1

统计网卡1的信息