Linux下很全面的监控工具dstat

dstat -cndymilpg -N total 1  (监控系统资源命令)



1)  工具说明

dstat
是一个用来替换 vmstat,iostat netstat,nfsstatifstat这些命令的工具,是一个全能系统信息统计工具.sysstat相比, dstat拥有一个彩色的界面,在手动观察性能状况时,数据比较显眼容易观察;而且dstat支持即时刷新,譬如输入dstat 3,即每三秒收集一次, 但最新的数据都会每秒刷新显示. sysstat相同的是, dstat也可以收集指定的性能资源,譬如 dstat -c即显示CPU的使用情况.
下载安装文件dstat-0.6.7-1.el*.rf.noarch.rpm:http://dag.wieers.com/rpm/packages/dstat/

2) 
软件安装

# cd /tmp
# rz (
上传安装包)
# rpm -Uvh dstat-0.6.7-1.el*.rf.noarch.rpm
# which dstat
/usr/bin/dstat

3) 
使用示例

# dstat
安装完成后, 执行 dstat 命令,默认情况它会收集-cpu-,-disk-,-net-,paging-,-system-的数据,一秒钟收集一次. 默认输入dstat等于输入了dstat -cdngy 1dstat -a 1.推荐使用 date &&dstat -tclmdny 60一分钟监视一次(注意调节显示的宽度,或去掉-t选项).

4)  dstat
选项

-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
-I5,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 externalstats
-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文件中
这个软件和vmstat很像,不过和vmstat相比好像少了io部份的显示, dstat只能显示磁盘的吞吐量而不是显示负载情况, dstat和几乎所有监控软件一样,只能对整个系统进行监控而不能对某一个进程或某一个程序进行深入分析.我常使用的参数是dstat -cdlmnpsy,做个别名链接alias dstat='dstat-cdlmnpsy'

refer: http://selboo.com.cn/read.php?637

因此在这里分享一下这个用python写的工具。

$dstat

----total-cpu-usage-----dsk/total- -net/total- ---paging-- ---system--

usr sys idl wai hiqsiq| read writ| recv  send| in   out | int   csw

  2  0  98   0  0   0|  80k  54k|   0     0 | 335B 381B|1297  1301

 22  2  74   0  0   2|   0  416k| 621k  219k|   0    0 |1158    26k

 23  3  72   0  0   2|  64k 484k|  11k   11k|  0     0 |1109    30k

 21  3  75   0  0   2|4096B  416k|  77k  77k|   0     0 |2104   25k

 29  4  66   0  0   2|   0 1240k| 996k  425k|   0    0 |1350    28k

$dstat -ta --outputosstat.csv

-----time---------total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--

  date/time  |usr sys idl wai hiq siq| read writ| recv  send|  in  out | int   csw

05-0211:37:08| 2   0 98   0   0  0|  80k   54k|  0     0 | 335B  381B|1297 1301

05-02 11:37:09|16  4 78   0   0   3|   0 1404k|1478k  939k|   0    0 |4316    33k

05-02 11:37:10| 20  2 76   0   0  2|   0  1144k|1109k 828k|   0     0 |5653   28k

05-02 11:37:11|13  2 83   0   0   2|   0  588k|2590k 1684k|   0     0 |4256   23k

$dstat -h

Usage: dstat [-afv][options..] [delay [count]]

Versatile tool forgenerating 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 usedby 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

     -S swap1,total         include swap1 and total

  -t, --time             enable time/date output

  -T, --epoch            enable time counter (seconds sinceepoch)

  -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 -C, -D, -I, -N and -Sdiscovery 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 eachupdate

  count is the number of updates to displaybefore exiting

  The default delay is 1 and count isunspecified (unlimited)

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值