Chinaunix首页 | 论坛 | 博客
  • 博客访问: 140742
  • 博文数量: 68
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-28 20:01
文章分类

全部博文(68)

文章存档

2015年(68)

我的朋友

分类: 系统运维

2015-08-31 18:23:20

简介:

Collectl是一个非常好的linux性能监控工具,通过Collectl能监控的东西很多,像cpu、内存、磁盘、进程、网络、nfs、tcp、socket等。

安装:

本人的一贯想法,在安装linux的软件时能用软件包安装的尽量用软件包来安装,方便快捷。

[root@server_32 ~]# yum search collectl

需用源码编绎安装可以到 style="font-size:14px;"> 上下载安装。

使用示例:

Collectl监控的东西很多,相应的,可用的参数和选项也很多,详细可以用man colloect来看一下。





(1)什么参数都不带,则每隔一秒输出cpu、磁盘、网络的简短信息


[root@cfserver ~]# collectl 

waiting for 1 second sample...

#<--------CPU--------><----------Disks-----------><----------Network---------->

#cpu sys inter  ctxsw KBRead  Reads KBWrit Writes   KBIn  PktIn  KBOut  PktOut 

  25  24  1104   1061      0      0      0      0      3     22      8      21 

  25  24  1101    909     48      2     12      2      2     24      3      21 

  25  24  1144   1163      0      0      0      0      6     46     11      46 

(2)监控cpu


[root@cfserver ~]# collectl -scj --top

-s表示要监控子系统,c/j表示要监控的子系统为cpu和cpu中断,在监控子系统的选项中,使用小写表输出简单信息,大写则输入详细信息。


waiting for 1 second sample...

#<--------CPU--------><-------Int-------->

#cpu sys inter  ctxsw Cpu0 Cpu1 Cpu2 Cpu3 

  25  24  1087    910 2086  999 1000  999 

  26  24  1149   1265 2149 1000 1001 1000 

  25  24  1129   1150 2129 1001 1000 1001 

[root@cfserver ~]# collectl -sCj --top  #top选项,像系统top那样实时显示


### RECORD   47 >>> cfserver <<< (1326248562.002) (Wed Jan 11 10:22:42 2012) ###

# SINGLE CPU STATISTICS

#   Cpu  User Nice  Sys Wait IRQ  Soft Steal Idle INTRPT

      0     1    0    1    0    0    0     0   98   2068

      1     4    0    1    0    0    0     0   95   1000

      2     3    0   12    0    0    0     0   85   1000

      3     2    0   86    0    0    0     0   11   1001

 

# TOP PROCESSES sorted by time (counters are /sec) 10:22:42

# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime MajF MinF Command

31489  daemon   25  3533    0 R  169M   14M  3  0.97  0.02  99  30149:05    0    0 /usr/local/apache/bin/httpd 

 9445  root     18  5421    0 R  112M   18M  2  0.02  0.04   6   0:03.04    0    0 /usr/bin/perl 

13963  mysql    15 13892   11 S    1G  175M  2  0.00  0.01   1 102:17.84    0    0 /usr/local/mysql/libexec/mysqld 

19673  daemon   16  3533    0 S  163M    8M  0  0.00  0.01   1   0:26.90    0    1 /usr/local/apache/bin/httpd 

    1  root     15     0    0 S   10M  576K  3  0.00  0.00   0  39:45.59    0    0 init 

    2  root     RT     1    0 S     0     0  0  0.00  0.00   0   1:49.38    0    0 migration/0 

    3  root     34     1    0 S     0     0  0  0.00  0.00   0   4:28.79    0    0 ksoftirqd/0 

    4  root     RT     1    0 S     0     0  0  0.00  0.00   0   0:00.00    0    0 watchdog/0 

    5  root     RT     1    0 S     0     0  1  0.00  0.00   0   1:44.35    0    0 migration/1 

    6  root     34     1    0 S     0     0  1  0.00  0.00   0   0:46.23    0    0 ksoftirqd/1 

    7  root     RT     1    0 S     0     0  1  0.00  0.00   0   0:00.00    0    0 watchdog/1 

    8  root     RT     1    0 S     0     0  2  0.00  0.00   0   2:13.13    0    0 migration/2 

    9  root     34     1    0 S     0     0  2  0.00  0.00   0   0:04.87    0    0 ksoftirqd/2 

   10  root     RT     1    0 S     0     0  2  0.00  0.00   0   0:00.00    0    0 watchdog/2

(3)监控磁盘


[root@cfserver ~]# collectl -sD

waiting for 1 second sample...

# DISK STATISTICS (/sec)

#          <---------reads---------><---------writes---------><--------averages--------> Pct

#Name       KBytes Merged  IOs Size  KBytes Merged  IOs Size  RWSize  QLen  Wait SvcTim Util

sda              0            0         0     0         0           0        0      0         0           0       0        0        0

sdb              0            0         0     0         0           0        0      0         0           0       0        0        0

hda              0            0         0     0         0           0        0      0         0           0       0        0        0

sda              0            0         0     0      1612       97     337    5         4          80    186      2        73

可以看到主要为写操作,且全部发生在sda,我们可以过滤一下



[root@cfserver ~]# collectl -sD --dskfilt sda  #可以多个,如^sd,dm包含sd开头及dm的磁盘

waiting for 1 second sample...

# DISK STATISTICS (/sec)

#                <---------reads------------><-------------writes---------><-------------averages--------------> Pct

#Name       KBytes Merged  IOs Size  KBytes Merged  IOs Size  RWSize  QLen  Wait SvcTim Util

sda                     0           0      0     0     1920         19  443    4            4       88     242         2   97



sda                     0           0      0     0       552       103    35   16           15       0       22         2    7

sda                     0           0      0     0         24           3      3    8             8         0        7         7    2

从上面看到sda有一次IOPS为443,等待wait为242,可以说磁盘IO是有一些问题的。

(4)监控内存


[root@cfserver ~]# collectl -sM

waiting for 1 second sample...

 

# MEMORY STATISTICS 

# Node    Total     Used     Free        Slab       Mapped      Anon      Inact     Hit%

     0    4023M    3422M  615488K  171212K   33980K    2539M  267728K    0

     0    4023M    3422M  615488K  171212K   33984K    2539M  267728K    0

     0    4023M    3422M  615488K  171212K   33984K    2539M  267732K    0

 (5)监控进程


[root@cfserver data]# collectl -sZ --procfilt Cnginx --procopts c  #监控nginx进程

waiting for 60 second sample...

# PROCESS SUMMARY (counters are /sec)

# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime MajF MinF Command

 4798  root     21     1    0 S   36M    4M  2  0.00  0.00   0 132:01.89    0    0 nginx: 

29298  nobody   15  4798    0 S   41M    8M  0  0.03  0.03   0   4:29.77    0    0 nginx: 

29299  nobody   15  4798    0 S   41M    8M  3  0.00  0.00   0   4:28.23    0    0 nginx: 

29300  nobody   15  4798    0 S   41M    8M  0  0.00  0.00   0   4:43.83    0    0 nginx: 

29301  nobody   15  4798    0 S   41M    8M  0  0.00  0.00   0   4:19.98    0    0 nginx: 


简单介绍到这,上面示例只是collectl冰山中很小的一角,更多用法可到官网看看文档。

阅读(984) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~