上一篇文章是转发了官方的zabbix监控squid的模版,兴奋之余把这个模版导入到squid后,却发现官方模版需要经过你的定制才能真正达到你的需求!
比如我导入模版之后,却发现没法出squid图片!
具体情况: 软件:squid 2.7 侦听端口: 8088
要实现在zabbix上监控squid, 要先看zabbix是如何获知squid的相关信息,squidclient mgr:info
完成以下三步,修改下模版即可完成你的监控需求!
第一步: 导入官方zabbix_server模版吧!上一篇文章附件中的模版!
第二步: 开启mgr的访问权限!
acl mgrcheng src 127.0.0.1
acl manager proto cache_object
http_access allow manager mgrcheng
http_access deny all
第二步:修改zabbix的客户端
我在原来的模块基础上根据我的环境修改了路径,添加了端口!
- # Squid
- UserParameter=squid.http_requests,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of HTTP requests received:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.clients,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of clients accessing cache:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.icp_received,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of ICP messages received:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.icp_sent,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of ICP messages sent:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.icp_queued,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of queued ICP replies:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.htcp_received,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of HTCP messages received:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.htcp_sent,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Number of HTCP messages sent:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.req_fail_ratio,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Request failure ratio:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.avg_http_req_per_min,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Average HTTP requests per minute since start:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.avg_icp_msg_per_min,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Average ICP messages per minute since start:'|cut -d':' -f2| tr -d ' \t'
- UserParameter=squid.request_hit_ratio,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Request Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.byte_hit_ratio,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Byte Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.request_mem_hit_ratio,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Request Memory Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.request_disk_hit_ratio,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Request Disk Hit Ratios:'|cut -d':' -f3|cut -d',' -f1|tr -d ' %'
- UserParameter=squid.servicetime_httpreq,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'HTTP Requests (All):'|cut -d':' -f2|tr -s ' '|awk '{print $1}'
- UserParameter=squid.process_mem,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Process Data Segment Size via sbrk'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.cpu_usage,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'CPU Usage:'|cut -d':' -f2|tr -d '%'|tr -d ' \t'
- UserParameter=squid.cache_size_disk,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Storage Swap size:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.cache_size_mem,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Storage Mem size:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.mean_obj_size,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Mean Object Size:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.filedescr_max,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Maximum number of file descriptors:'|cut -d':' -f2|awk '{print $1}'
- UserParameter=squid.filedescr_avail,/usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Available number of file descriptors:'|cut -d':' -f2|awk '{print $1}'
- [root@root ~]# /usr/local/squid/bin/squidclient -p 8088 mgr:info|grep 'Available number of file descriptors:'|cut -d':' -f2|awk '{print $1}'
有图才有真相!