本文来自官方文档
Monitoring a Squid web cache/proxyx
The following recipe/template uses the 'squidclient' shell program to gather information about a running Squid web cache/proxy. So make sure that you get statistical data when running:
-
squidclient mgr:info
On the server running Squid you will need to run the Zabbix agent and add these lines to the /etc/zabbix/zabbix_agentd.conf:
- # Squid
- UserParameter=squid.http_requests,squidclient mgr:info|grep 'Number of HTTP requests received:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.clients,squidclient mgr:info|grep 'Number of clients accessing cache:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.icp_received,squidclient mgr:info|grep 'Number of ICP messages received:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.icp_sent,squidclient mgr:info|grep 'Number of ICP messages sent:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.icp_queued,squidclient mgr:info|grep 'Number of queued ICP replies:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.htcp_received,squidclient mgr:info|grep 'Number of HTCP messages received:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.htcp_sent,squidclient mgr:info|grep 'Number of HTCP messages sent:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.req_fail_ratio,squidclient mgr:info|grep 'Request failure ratio:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.avg_http_req_per_min,squidclient mgr:info|grep 'Average HTTP requests per minute since start:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.avg_icp_msg_per_min,squidclient mgr:info|grep 'Average ICP messages per minute since start:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.request_hit_ratio,squidclient mgr:info|grep 'Request Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.byte_hit_ratio,squidclient mgr:info|grep 'Byte Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.request_mem_hit_ratio,squidclient mgr:info|grep 'Request Memory Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.request_disk_hit_ratio,squidclient mgr:info|grep 'Request Disk Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.servicetime_httpreq,squidclient mgr:info|grep 'HTTP Requests (All):'|cut -d':' -f2|tr -s ' '|awk '{print $1}'
- UserParameter=squid.process_mem,squidclient mgr:info|grep 'Process Data Segment Size via sbrk'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.cpu_usage,squidclient mgr:info|grep 'CPU Usage:'|cut -d':' -f2|tr -d '%'|tr -d ' \t'
- UserParameter=squid.cache_size_disk,squidclient mgr:info|grep 'Storage Swap size:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.cache_size_mem,squidclient mgr:info|grep 'Storage Mem size:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.mean_obj_size,squidclient mgr:info|grep 'Mean Object Size:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.filedescr_max,squidclient mgr:info|grep 'Maximum number of file descriptors:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.filedescr_avail,squidclient mgr:info|grep 'Available number of file descriptors:'|cut -d':' -f2|awk '{print $1}'