squid日常维护

好久之前使用squid时记录的笔记,现在线上已经没有squid的设备了,估计以后也不会再看squid相关的资料了,发出来,留个记录。

squidclient客户端的简单实用

1.访问不需要密码

squidclient -p 80 mgr:menu

2.访问需要密码

[root@cnc peiqiang]# grep 'cachemgr_passwd' /data1/squid/etc/squid81.conf
cachemgr_passwd hyrzxc all
[root@cnc peiqiang]# /data1/squid/bin/squidclient -p 81 mgr:menu@hyrzxc
HTTP/1.0 200 OK
Server: sinuid/150.16
Date: Mon, 04 Aug 2014 06:29:40 GMT
Content-Type: text/plain
Expires: Mon, 04 Aug 2014 06:29:40 GMT
X-Cache: MISS from localhost
Via: 1.0 localhost:81 (sinuid/150.16)
Connection: close

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

3.查看下squid的运行信息

[root@cnc peiqiang]# /data1/squid/bin/squidclient -p 81 mgr:info@hyrzxc
HTTP/1.0 200 OK
Server: sinuid/150.16
Date: Thu, 07 Aug 2014 03:01:38 GMT
Content-Type: text/plain
Expires: Thu, 07 Aug 2014 03:01:38 GMT
X-Cache: MISS from localhost
Via: 1.0 localhost:81 (sinuid/150.16)
Connection: close

Squid Object Cache: Version 150.16
Start Time:     Wed, 16 Jul 2014 05:42:05 GMT
Current Time:   Thu, 07 Aug 2014 03:01:38 GMT
Connection information for squid:
        Number of clients accessing cache:      25
        Number of HTTP requests received:       1331910
        Number of ICP messages received:        0
        Number of ICP messages sent:    0
        Number of queued ICP replies:   0
        Request failure ratio:   0.00
        Average HTTP requests per minute since start:   42.3
        Average ICP messages per minute since start:    0.0
        Select loop called: 187761183 times, 10.072 ms avg
Cache information for squid:
        Request Hit Ratios:     5min: 95.3%, 60min: 94.9%
        Byte Hit Ratios:        5min: 98.4%, 60min: 99.6%
        Request Memory Hit Ratios:      5min: 99.2%, 60min: 98.7%
        Request Disk Hit Ratios:        5min: 0.0%, 60min: 0.5%
        Storage Swap size:      47140164 KB
        Storage Mem size:       4162148 KB
        Mean Object Size:       12282.48 KB
        Requests given to unlinkd:      8496
Median Service Times (seconds)  5 min    60 min:
        HTTP Requests (All):  10.20961  8.68295
        Cache Misses:          2.64709 24.21863
        Cache Hits:           10.77596  9.67302
        Near Hits:             0.06286  6.28029
        Not-Modified Replies:  0.00000  0.00000
        DNS Lookups:           0.00000  0.00000
        ICP Queries:           0.00000  0.00000
Resource usage for squid:
        UP Time:        1891172.595 seconds
        CPU Time:       20702.760 seconds
        CPU Usage:      1.09%
        CPU Usage, 5 minute avg:        4.44%
        CPU Usage, 60 minute avg:       3.75%
        Process Data Segment Size via sbrk(): 4309008 KB
        Maximum Resident Size: 17273296 KB
        Page faults with physical i/o: 6
Memory usage for squid via mallinfo():
        Total space in arena:  114708 KB
        Ordinary blocks:       114654 KB     78 blks
        Small blocks:               0 KB      0 blks
        Holding blocks:         45424 KB      5 blks
        Free Small blocks:          0 KB
        Free Ordinary blocks:      53 KB
        Total in use:          160078 KB 100%
        Total free:                53 KB 0%
        Total size:            160132 KB
Memory accounted for:
        Total accounted:       4279829 KB
        memPoolAlloc calls: 332581098
        memPoolFree calls: 331414498
File descriptor usage for squid:
        Maximum number of file descriptors:   102400
        Largest file desc currently in use:     73
        Number of file desc currently in use:   54
        Files queued for open:                   0
        Available number of file descriptors: 102346
        Reserved number of file descriptors:   100
        Store Disk files open:                   0
        IO loop method:                     epoll
Internal Data Structures:
          3864 StoreEntries
           380 StoreEntries with MemObjects
           379 Hot Object Cache Items
          3838 on-disk objects

参考资料:

官方文档:http://wiki.squid-cache.org/SquidClientTool

squidclient服务端Squid的配置:http://wangxiaoyu.blog.51cto.com/922065/527265

squid client用法讲解:http://etutorials.org/Server+Administration/Squid.+The+definitive+guide/Chapter+14.+Monitoring+Squid/14.2+The+Cache+Manager/