squid的mgr强大功能介绍(转)

squid的mgr可以提供某台正在运行中的squid的实时监控数据,这些数据不仅可以帮助我们分析squid的运行状态和缓存的效果,而且还有很多很多的秘密和玄机藏在里面噢。很多时候觉得squid已经非常优化,查看mgr之后或许会大吃一惊。

mgr的常用命令行:

/usr/local/squid/bin/squidclient -h 127.0.0.1 -p 80 mgr:info

其中-h指定ip地址,-p指定端口,mgr:info是mgr的最常用的指令,指令还有很多,执行:

/usr/local/squid/bin/squidclient -h 127.0.0.1 -p 80 mgr:

这行语句比前一句少了最后的一个info,这样就会打印出可用的指令了,指令太多,我还没有能摸索完……见附件1

记住几个指令:mgr:info mgr:5min mgr:60min,没事做的时候就敲敲。

mgr:info可以说是最常用的了,它提供了一个概述,请求量、命中率、缓存数量等等都包含在内,我就不一条条说了,不懂英文可找翻译。

另外,这些指令有一些是消耗系统资源比较大的,所以请勿在重要场合尝试,免得造成困扰。如果非要尝试,附件2中倒有一堆测试机。

如果无法正常查看mgr,证明是squid配置中关闭了mgr的访问权限,那么需要在squid配置里加上几句话打开权限:

acl adminBoxes src 127.0.0.1
acl manager proto cache_object
http_access allow manager adminBoxes
http_access deny all

我可以发誓,配置这几句话并不会把你的机器变成一台新的测试机,里面有几行可能跟原来配置重叠,这是强调,并且语句前后顺序也不能变。

其中只有一个常要改的东西,就是ip地址,这里配置的是本机,可以增加:

acl adminBoxes src 127.0.0.1 192.168.1.100

可以支持一个网段:

acl adminBoxes src 127.0.0.1 192.168.1.100 192.168.51.0/24

配好之后要记得reload一下squid

squid -k reconfigure

 


附件1(mgr指令大全)
mem                    Memory Utilization      public
cbdata                 Callback Data Registry Contents public
events                 Event Queue     public
squidaio_counts        Async IO Function Counters      public
config                 Current Squid Configuration     hidden
ipcache                IP Cache Stats and Contents     public
fqdncache              FQDN Cache Stats and Contents   public
idns                   Internal DNS Statistics public
external_acl           External ACL stats      public
http_headers           HTTP Header Statistics  public
menu                   This Cachemanager Menu  public
shutdown               Shut Down the Squid Process     hidden
offline_toggle         Toggle offline_mode setting     hidden
info                   General Runtime Information     public
filedescriptors        Process Filedescriptor Allocation       public
objects                All Cache Objects       public
vm_objects             In-Memory and In-Transit Objects        public
openfd_objects         Objects with Swapout files open public
pending_objects        Objects being retreived from the network        public
client_objects         Objects being sent to clients   public
io                     Server-side network read() size histograms      public
counters               Traffic and Resource Counters   public
peer_select            Peer Selection Algorithms       public
digest_stats           Cache Digest and ICP blob       public
5min                   5 Minute Average of Counters    public
60min                  60 Minute Average of Counters   public
utilization            Cache Utilization       public
histograms             Full Histogram Counts   public
active_requests        Client-side Active Requests     public
storedir               Store Directory Stats   public
store_check_cachable_stats     storeCheckCachable() Stats      public
store_io               Store IO Interface Stats        public
pconn                  Persistent Connection Utilization Histograms    public
refresh                Refresh Algorithm Statistics    public
forward                Request Forwarding Statistics   public
client_list            Cache Client List       public
asndb                  AS Number Database      public

  测试域名
squidclient -h www.youku.com -p 80 mgr:info
squidclient -h www.cctv.com -p 80 mgr:info
squidclient -h www.xinhuanet.com -p 80 mgr:info
squidclient -h www.people.com.cn -p 80 mgr:info
squidclient -h www.kuaiche.com -p 80 mgr:info
squidclient -h www.it168.com -p 80 mgr:info
squidclient -h www.qidian.com -p 80 mgr:info
squidclient -h www.vodone.com -p 80 mgr:info
squidclient -h www.hc360.com -p 80 mgr:info
squidclient -h www.12530.com -p 80 mgr:info
squidclient -h www.verycd.com -p 80 mgr:info
squidclient -h www.9you.com -p 80 mgr:info
squidclient -h www.duowan.com -p 80 mgr:info
squidclient -h www.poco.cn -p 80 mgr:info
squidclient -h www.blogchina.com -p 80 mgr:info

由附件2看来,中国使用squid作前端的网站还是非常多,附件2中有一部分都是CDN来的,机器多维护起来也晕乎晕乎。

现在是2009年3月17日4时,假如他们近期改掉了毛病,那证明这篇文章的传播速度还是挺快的
###############################
另附
[root@D08043450 /root]# date
Thu Oct 29 11:45:46 CST 2009
[root@D08043450 /root]# /usr/local/squid/bin/squidclient -h www.youku.com -p 80 mgr:
HTTP/1.0 200 OK
Server: squid/2.5.STABLE13
Mime-Version: 1.0
Date: Thu, 29 Oct 2009 03:52:50 GMT
Content-Type: text/plain
Expires: Thu, 29 Oct 2009 03:52:50 GMT
Last-Modified: Thu, 29 Oct 2009 03:52:50 GMT
X-Cache: MISS from a05.www
Proxy-Connection: close
 
 mem                    Memory Utilization      public
 cbdata                 Callback Data Registry Contents public
 events                 Event Queue     public
 squidaio_counts        Async IO Function Counters      public
 diskd                  DISKD Stats     public
 config                 Current Squid Configuration     hidden
 comm_incoming          comm_incoming() stats   public
 ipcache                IP Cache Stats and Contents     public
 fqdncache              FQDN Cache Stats and Contents   public
 dns                    Dnsserver Statistics    public
 external_acl           External ACL stats      public
 http_headers           HTTP Header Statistics  public
 menu                   This Cachemanager Menu  public
 shutdown               Shut Down the Squid Process     hidden
 offline_toggle         Toggle offline_mode setting     hidden
 info                   General Runtime Information     public
 filedescriptors        Process Filedescriptor Allocation       public
 objects                All Cache Objects       public
 vm_objects             In-Memory and In-Transit Objects        public
 openfd_objects         Objects with Swapout files open public
 pending_objects        Objects being retreived from the network        public
 client_objects         Objects being sent to clients   public
 io                     Server-side network read() size histograms      public
 counters               Traffic and Resource Counters   public
 peer_select            Peer Selection Algorithms       public
 digest_stats           Cache Digest and ICP blob       public
 5min                   5 Minute Average of Counters    public
 60min                  60 Minute Average of Counters   public
 utilization            Cache Utilization       public
 histograms             Full Histogram Counts   public
 active_requests        Client-side Active Requests     public
 storedir               Store Directory Stats   public
 store_check_cachable_stats     storeCheckCachable() Stats      public
 store_io               Store IO Interface Stats        public
 pconn                  Persistent Connection Utilization Histograms    public
 refresh                Refresh Algorithm Statistics    public
 forward                Request Forwarding Statistics   public
 client_list            Cache Client List       public
 netdb                  Network Measurement Database    public
 asndb                  AS Number Database      public

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zzz_781111/archive/2009/10/29/4742263.aspx

posted on 2009-11-22 09:42  feney  阅读(1264)  评论(0编辑  收藏  举报