Press "Enter" to skip to content

标签: 监测工具

采用Linux性能监测工具dstat来分析系统资源情况

日常管理中使用需要经常查看服务器状态和性能,比如IO占用情况,及内存使用情况,硬盘,CPU等等。网络上搜罗了一下,这个dstat软件还是比较不错能满足日常分析。本人采用的是X64系统,在CentOS6.2系统下采用yum进行安装dstat软件
默认情况它会收集 cpu、disk、net、paging、system 数据,一秒钟收集一次

[root@kiccleaf ~]# dstat  #运行命令是否已经安装
-bash: dstat: command not found   #没有找到此命令
[root@kiccleaf ~]# yum install dstat   #进行安装
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                            | 3.7 kB     00:00     
extras                                          | 3.5 kB     00:00     
updates                                         | 3.5 kB     00:00     
updates/primary_db                              | 654 kB     00:02     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dstat.noarch 0:0.7.0-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================
 Package       Arch           Version               Repository    Size
=======================================================================
Installing:
 dstat         noarch         0.7.0-1.el6           base         144 k

Transaction Summary
=======================================================================
Install       1 Package(s)

Total download size: 144 k
Installed size: 660 k
Is this ok [y/N]: y  #输入y进行安装
Downloading Packages:
dstat-0.7.0-1.el6.noarch.rpm                    | 144 kB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : dstat-0.7.0-1.el6.noarch                            1/1 

Installed:
  dstat.noarch 0:0.7.0-1.el6                                           

Complete!
[root@kiccleaf ~]# dstat -d   #查看硬盘IO操作
-dsk/total-
 read  writ
 861k   90k
   0     0 
   0    68k
4096B 1216k
   0   112k
[root@kiccleaf ~]# dstat -h   #查看帮助文档
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics

Dstat options:
  -c, --cpu              enable cpu stats 显示CPU情况
     -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 显示swap情况
     -S swap1,total         include swap1 and total 可以指定多个swap
  -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 报告IPC消息队列和信号量的使用情况
  --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) 使用-cdngy 缺省的就是这样显示
  -f, --full             automatically expand -C, -D, -I, -N and -S lists 使用 -C, -D, -I, -N and -S 显示
  -v, --vmstat           equals -pmgdsc -D total 使用-pmgdsc -D 显示

  --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)

较为长用的命令,来观察系统运行情况
#如果你想10秒收集一次,就输入: dstat -cdlmnpsy 10

[root@kiccleaf ~]# dstat -cdlmnpsy
----total-cpu-usage---- -dsk/total- ---load-avg--- ------memory-usage----- -net/total- ---procs--- ----swap--- ---system--
usr sys idl wai hiq siq| read  writ| 1m   5m  15m | used  buff  cach  free| recv  send|run blk new| used  free| int   csw 
  0   0  99   0   0   0| 104k   14k|   0    0    0|66.9M 8332k 81.5M  837M|   0     0 |  0   0 1.3|   0  2016M|  65    44 
  0   0 100   0   0   0|   0     0 |   0    0    0|66.9M 8332k 81.5M  837M|  60B 1354B|  0   0   0|   0  2016M|  28    17 
  0   0 100   0   0   0|   0     0 |   0    0    0|66.9M 8332k 81.5M  837M|  60B  522B|  0   0   0|   0  2016M|  24    17 
  0   0 100   0   0   0|   0     0 |   0    0    0|66.9M 8332k 81.5M  837M|  60B  522B|  0   0   0|   0  2016M|  27    18 
  0   0 100   0   0   0|   0     0 |   0    0    0|66.9M 8332k 81.5M  837M| 552B  522B|  0   0   0|   0  2016M|  28    23 
  0   0 100   0   0   0|   0     0 |   0    0    0|66.9M 8332k 81.5M  837M|  60B  522B|  0   0   0|   0  2016M|  26    17 
  0   0 100   0   0   0|   0     0 |   0    0    0|66.9M 8332k 81.5M  837M| 491B  522B|  0   0   0|   0  2016M|  31    17

统计CPU,IO ,network,system load

[root@kiccleaf ~]# dstat -cndymlp -N total -D total 5 25
----total-cpu-usage---- -net/total- -dsk/total- ---system-- ------memory-usage----- ---load-avg--- ---procs---
usr sys idl wai hiq siq| recv  send| read  writ| int   csw | used  buff  cach  free| 1m   5m  15m |run blk new
  0   0  99   0   0   0|   0     0 |  96k   13k|  62    42 |66.8M 8332k 81.5M  837M|   0    0    0|  0   0 1.2
  0   0 100   0   0   0| 218B  636B|   0     0 |  27    19 |66.9M 8332k 81.5M  837M|   0    0    0|  0   0   0
  0   0 100   0   0   0| 242B  477B|   0     0 |  29    18 |66.9M 8332k 81.5M  837M|   0    0    0|  0   0   0
  0   0 100   0   0   0| 324B  479B|   0     0 |  28    18 |66.9M 8332k 81.5M  837M|   0    0    0|  0   0   0

统计网卡1的信息

[root@kiccleaf ~]# dstat -cdnsil -D hda -N eth1
Module dstat_disk24old failed to load. (No suitable block devices found to monitor)
Module dstat_net failed to load. (No suitable network interfaces found to monitor)
----total-cpu-usage---- ----swap--- ----interrupts--- ---load-avg---
usr sys idl wai hiq siq| used  free|  17    18    19 | 1m   5m  15m 
  0   0  99   0   0   0|   0  2016M|   4     0     3 |   0    0    0
  0   0 100   0   0   0|   0  2016M|   0     0     3 |   0    0    0
  0   0 100   0   0   0|   0  2016M|   0     0     4 |   0    0    0
  0   0 100   0   0   0|   0  2016M|   0     0     3 |   0    0    0
  0   0 100   0   0   0|   0  2016M|   0     0     4 |   0    0    0

内存使用情况

[root@kiccleaf ~]# dstat -vmstat
Terminal width too small, trimming output.
---procs--- ------memory-usage----- ---paging-- -dsk/total- ---system-- ----total-cpu-usage---- ------memory-usage----- ----swap--- ----system---- ----total-cpu-usage---->
run blk new| used  buff  cach  free|  in   out | read  writ| int   csw |usr sys idl wai hiq siq| used  buff  cach  free| used  free|  date/time   |usr sys idl wai hiq siq>
0.0   0 1.1|66.8M 8332k 81.5M  837M|   0     0 |  88k   12k|  59    40 |  0   0  99   0   0   0|66.8M 8332k 81.5M  837M|   0  2016M|05-01 21:52:57|  0   0  99   0   0   0>
  0   0   0|66.8M 8340k 81.5M  837M|   0     0 |   0    12k|  40    27 |  0   0 100   0   0   0|66.8M 8340k 81.5M  837M|   0  2016M|05-01 21:52:58|  0   0 100   0   0   0>
  0   0   0|66.8M 8340k 81.5M  837M|   0     0 |   0     0 |  31    21 |  0   0 100   0   0   0|66.8M 8340k 81.5M  837M|   0  2016M|05-01 21:52:59|  0   0 100   0   0   0>
  0   0   0|66.8M 8340k 81.5M  837M|   0     0 |   0     0 |  28    16 |  0   0 100   0   0   0|66.8M 8340k 81.5M  837M|   0  2016M|05-01 21:53:00|  0   0 100   0   0   0>
  0   0   0|66.8M 8340k 81.5M  837M|   0     0 |   0     0 |  36    19 |  0   0 100   0   0   0|66.8M 8340k 81.5M  837M|   0  2016M|05-01 21:53:01|  0   0 100   0   0   0>

Leave a Comment