เมื่อต้องการทราบรายละเอียดการทำงานของ Squid เราสามารถใช้คำสั่ง squidclient เพื่อใช้ในการขอดูข้อมูลต่างๆ ใน Squid
* Squid คือ โปรแกรมที่ทำหน้่่าที่เป็น proxy server ในระบบปฏิบัติการ linux หรือ Unix
* squidclient เป็น tool ที่ใช้สำหรับการเข้าถึง squid service และดูข้อมูลต่างๆเกี่ยวกับ squid เช่น performance statistic, Average HTTP requests per minutes, Request Hit Ratios, Requests Median Service Time
การดู performance statistic ของ squid จะใช้คำสั่ง
#squidclient -p <port> mgr:info
[root@Squid_Proxy ~]# squidclient -p 3128 mgr:info
HTTP/1.0 200 OK
Server: squid/2.6.STABLE6
Date: Mon, 25 May 2009 17:14:47 GMT
Content-Type: text/plain
Expires: Mon, 25 May 2009 17:14:47 GMT
Last-Modified: Mon, 25 May 2009 17:14:47 GMT
X-Cache: MISS from Squid_Proxy.example.com
X-Cache-Lookup: MISS from Squid_Proxy.example.com:3128
Via: 1.0 Squid_Proxy.example.com:3128 (squid/2.6.STABLE6)
Proxy-Connection: close
Squid Object Cache: Version 2.6.STABLE6
Start Time: Mon, 25 May 2009 17:14:32 GMT
Current Time: Mon, 25 May 2009 17:14:47 GMT
Connection information for squid:
Number of clients accessing cache: 1
Number of HTTP requests received: 0
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: 0.0
Average ICP messages per minute since start: 0.0
Select loop called: 6082 times, 2.478 ms avg
Cache information for squid:
Request Hit Ratios: 5min: 0.0%, 60min: 0.0%
Byte Hit Ratios: 5min: -0.0%, 60min: -0.0%
Request Memory Hit Ratios: 5min: 0.0%, 60min: 0.0%
Request Disk Hit Ratios: 5min: 0.0%, 60min: 0.0%
Storage Swap size: 0 KB
Storage Mem size: 108 KB
Mean Object Size: 0.00 KB
Requests given to unlinkd: 0
Median Service Times (seconds) 5 min 60 min:
HTTP Requests (All): 0.00000 0.00000
Cache Misses: 0.00000 0.00000
Cache Hits: 0.00000 0.00000
Near Hits: 0.00000 0.00000
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: 15.071 seconds
CPU Time: 0.014 seconds
CPU Usage: 0.09%
CPU Usage, 5 minute avg: 0.00%
CPU Usage, 60 minute avg: 0.00%
Process Data Segment Size via sbrk(): 2776 KB
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
Total space in arena: 2908 KB
Ordinary blocks: 2872 KB 3 blks
Small blocks: 0 KB 0 blks
Holding blocks: 356 KB 1 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 35 KB
Total in use: 3228 KB 99%
Total free: 35 KB 1%
Total size: 3264 KB
Memory accounted for:
Total accounted: 158 KB
memPoolAlloc calls: 985
memPoolFree calls: 314
File descriptor usage for squid:
Maximum number of file descriptors: 1024
Largest file desc currently in use: 13
Number of file desc currently in use: 11
Files queued for open: 0
Available number of file descriptors: 1013
Reserved number of file descriptors: 100
Store Disk files open: 0
IO loop method: epoll
Internal Data Structures:
27 StoreEntries
27 StoreEntries with MemObjects
26 Hot Object Cache Items
0 on-disk objects
Tags: Squidclient, Status SquidPosted by Comments Off
ถ้า squid คุณเกิดปัญหาหรือ error message ขึ้นว่า WARNING! Your cache is running out of filedescriptors ในไฟล์ cache.log แสดงว่า Squid version ที่ใช้อยู่ได้ compile ให้ไฟล์ file descriptors ให้สามารถใช้ได้มากสุด 1024 ซึ่งปัญหานี้เราไม่สามารถแก้ไขด้วยวิธีการใช้ ulimit ได้โดยตรง
ใน Squid ที่ support จะมี option max_filedesc เพิ่มขึ้นมาเพื่อใช้ในกาีรแก้ไขปัญหานี้
Linux ที่ support (ตอนนี้ทราบแต่ทาง Red Hat)
Red Hat Enterprise Linux 3: squid-2.5.STABLE3-6.3E.18
Red Hat Enterprise Linux 4: squid-2.5.STABLE14-1.4E
Red Hat Enterprise Linux 5
ส่วนวิธีการแก้ไขนั้นเราสามารถทำได้ตามขั้นตอนข้างล่างนี้ได้เลยครับ
1. แก้ไขไฟล์ /etc/security/limits.conf โดยให้เพิ่มข้อความด้านล่างเข้าไปในไฟล์
* – nofile 4096
2. ทำการ re-login (กด Ctrl-D ก็ได้ครับ) เข้าสู่ระบบให้เพื่อให้ทำการโหลด Config ค่าที่ได้แก้ไขไปเมื่อกี้ จากนั้นให้พิมพ์เพื่อทำการตรวจสอบว่าค่าที่ได้แก้ไขถูกโหลดขึ้นมาแล้ว
# ulimit -a
open files (-n) 4096
3. แก้ไขไฟล์ /etc/squid/squid.conf แล้วเพิ่มค่าด้านล่างเข้าไป
max_filedesc 4096
ค่าที่ได้แก้ไขควรที่จะมี่าเท่ากับค่าที่แก้ไขในไฟล์ /etc/security/limits.conf ในข้อที่ 1.
4. ทำการ Restart squid service:
# service squid restart
5. พิมพ์ squidclient เพื่อตรวจสอบว่า squid ได้โหลดคอนฟิกเป็นที่เรียบร้อยแล้วดังคำสั่งด้านล่าง
# squidclient mgr:info
File descriptor usage for squid:
Maximum number of file descriptors: 4096
Posted by (0) Comment
การเซ็ต transparent proxy ใน squid 2.6 จะใส่แค่ค่า
http_port 8080 transparent
แทน (version เก่า)
http_port 8080
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
และเซ็ต iptables
echo “1″ > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -t nat -F
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 8080