推荐一个强大的性能监测工具dstat

在进行性能测试的时候,我们一般需要检测很多方面的数据,这些数据包括CPU占用,内存占用情况,网络状况,load average,进程信息,磁盘信息等等。利用系统提供的命令一般来说可以完成这些数据的监测,但是一般来说,这些命令都是分散的,比如vmstat,iostat,netstat。如果能有一个工具可以完成这些数据的集中监控就好了。

dstat就是这样一款功能强大的工具,他完全覆盖了上述的功能集合,而且提供了更加强大的功能,下面是简单的一个dstat的用法说明和实例:

[dag@emyn ~]$ dstat –help
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
-s, –swap enable swap stats
-t, –time enable time counter
-y, –sys enable system stats
–ipc enable ipc stats
–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 equals -cdngy (default)
-f, –full expand -D, -I and -N discovery lists
-v, –vmstat equals -pmgdsc -D total

–integer show integer values
–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
count is the number of updates to display before exiting
The default delay is 1 and count is unspecified (unlimited)

Screenshot 2
Only in black and white 🙂

[dag@emyn ~]$ dstat –vmstat
—procs— ——memory-usage—– —paging– -disk/total —system– —-total-cpu-usage—-
run blk new|_used _free _buff _cach|__in_ _out_|_read write|_int_ _csw_|usr sys idl wai hiq siq
0 0 0| 324M 11.0M 40.5M 128M| 0 0 | 0 0 | 0 0 | 12 5 81 2 0 0
0 0 0| 324M 10.9M 40.5M 128M| 0 0 | 0 0 |1193 2098 | 10 6 83 0 1 0
7 0 26| 325M 9.84M 40.5M 128M| 0 0 | 0 0 |1184 2851 | 26 11 63 0 0 0
0 0 0| 326M 9568k 40.5M 128M| 0 0 | 0 0 |1187 2692 | 15 9 76 0 0 0
0 0 0| 326M 9568k 40.5M 128M| 0 0 | 0 0 |1195 1755 | 5 5 90 0 0 0
0 0 0| 326M 9568k 40.5M 128M| 0 0 | 0 0 |1207 1903 | 7 5 88 0 0 0
0 0 1| 324M 10.8M 40.5M 128M| 0 0 | 0 0 |1227 2184 | 13 7 79 0 1 0
0 0 0| 324M 10.8M 40.5M 128M| 0 0 | 0 48k|1214 1800 | 11 6 83 0 0 0
0 0 0| 324M 10.8M 40.5M 128M| 0 0 | 0 28.5k|1150 1778 | 5 4 90 0 1 0
0 0 0| 324M 10.8M 40.5M 128M| 0 0 | 0 0 |1254 1912 | 6 6 88 0 0 0
1 0 0| 324M 10.8M 40.5M 128M| 0 0 | 0 0 |1128 1807 | 5 4 91 0 0 0

Screenshot 3

[dag@emyn ~]$ dstat -cdnsil -D hda -N eth1
—-total-cpu-usage—- –disk/hda- –net/eth1- —-swap— —-interrupts— —load-avg—
usr sys idl wai hiq siq|_read write|_recv _send|_used _free|__12_ __14_ __15_|_1m_ _5m_ 15m_
12 5 81 2 0 0| 0 0 | 0 0 | 162M 362M| 0 0 0 |0.10 0.37 0.39
20 11 69 0 0 0| 0 512B|1708B 1674B| 162M 362M| 105 1 27 |0.10 0.37 0.39
32 8 60 0 0 0| 0 0 |9280B 2042B| 162M 362M| 126 0 24 |0.10 0.37 0.39
80 12 7 0 1 0| 0 0 |87.9k 15.6k| 162M 362M| 0 0 27 |0.10 0.37 0.39
26 9 65 0 0 0| 0 0 |23.5k 3576B| 162M 362M| 12 0 24 |0.10 0.37 0.39
13 7 80 0 0 0| 0 0 |36.8k 4885B| 162M 362M| 21 0 27 |0.10 0.37 0.39
7 5 88 0 0 0| 0 0 |3808B 210B| 162M 362M| 0 0 24 |0.10 0.37 0.39
3 6 89 1 1 0| 0 456k| 0 0 | 162M 362M| 0 32 27 |0.10 0.37 0.39
4 3 93 0 0 0| 0 109k| 0 0 | 162M 362M| 0 27 24 |0.10 0.37 0.39
7 5 88 0 0 0| 0 0 | 0 0 | 162M 362M| 60 0 27 |0.10 0.37 0.39

最新的版本是0.6.6-1,可以在下面的地址下载。

http://dag.wieers.com/rpm/packages/dstat/

一个简单的用法如下:

[root@strdq01 cdcora]# dstat -c -d -l -m -n -p
Terminal width too small, trimming output.
—-total-cpu-usage—- -dsk/total- —load-avg— ——memory-usage—– -net/total->
usr sys idl wai hiq siq| read writ| 1m 5m 15m | used buff cach free| recv send>
0 0 99 1 0 0| 77k 187k| 0.1 0 0| 448M 427M 3069M 2138M| 0 0 >
1 1 99 0 0 0| 40k 0 | 0.1 0 0| 448M 427M 3069M 2138M| 0 0 >
0 0 99 0 0 0| 16k 248k| 0.1 0 0| 448M 427M 3069M 2138M|1911k 1842k>
0 1 100 0 0 0| 64k 168k| 0.1 0 0| 448M 427M 3069M 2138M| 0 0 >
0 0 99 0 0 0| 40k 56k| 0.1 0 0| 448M 427M 3069M 2138M|1689k 1733k>
1 0 99 0 0 0| 16k 0 | 0.1 0 0| 448M 427M 3069M 2138M| 0 0 >
0 1 99 0 0 0| 112k 32k| 0.1 0 0| 448M 427M 3069M 2138M|2080k 2170k>
1 1 99 0 0 0| 24k 280k| 0.1 0 0| 448M 427M 3069M 2138M| 0 0 >
0 1 99 0 0 0| 48k 72k| 0.1 0 0| 448M 427M 3069M 2138M|2080k 2017k>
0 0 99 0 0 0| 48k 32k| 0.1 0 0| 448M 427M 3069M 2138M| 0 0 >
1 1 99 0 0 0| 24k 0 | 0.1 0 0| 448M 427M 3069M 2138M|1954k 1930k>
0 1 99 0 0 0| 32k 196k| 0.1 0 0| 448M 427M 3070M 2138M| 0 0 >
0 0 100 0 0 0| 48k 36k| 0.1 0 0| 448M 427M 3070M 2138M|1920k 1915k>
0 1 99 0 0 0| 40k 84k| 0.1 0 0| 448M 427M 3070M 2138M| 0 0 >
0 1 99 0 0 0| 32k 0 | 0.1 0 0| 448M 427M 3070M 2138M|2022k 2192k>

This entry was posted in 性能测试 and tagged . Bookmark the permalink.

7 Responses to 推荐一个强大的性能监测工具dstat

  1. 誰誰誰 says:

    这么复杂?sar不是也挺全的吗?还能写结果到一个BIN文件,将来再分门别类地分析

  2. totoloro says:

    这个工具在HP和AIX上都可以用吗?可以将信息打印到文件吗?

  3. ricky.zhu says:

    可以的,打印到文件就自己重定向咯,比如>> dstat.log

  4. showtime says:

    兄弟,介绍的这个工具真的很强大,3Q,非常实用且方便

  5. ricky.zhu says:

    或者用 –output savefile.log 也是可以的。

  6. tiffany says:

    这个能监控windows的吗

    • ricky.zhu says:

      It’s basically support on various Linux distro and you can download the source code.

      Red Hat Enterprise Linux / CentOS
      Fedora
      Gentoo
      OpenSUSE
      Debian
      Mandriva
      Alt Linux
      cAos
      Ubuntu Breezy
      Linspire
      Sourcemage
      rPath
      PLD Linux
      Slackware

Leave a Reply

Your email address will not be published. Required fields are marked *