zhuce 发表于 2018-12-27 06:57:04

配置cacti 监控squid

  类别:原创 服务器
   第一:说明,软件说明,和安装的目的
  使用cacti监控squid的各项参数,安装前请确保安装好了LMAP环境,mysql、apache、cacti、snmp、squid正常使用。
  cacti 主机ip 192.168.10.22    squid ip 192.168.10.21
  关于cacti的安装 请参照 《使用cacti + snmp 实现对apache 、mysql 、 nginx 的监控的安装和配置 》      
关于LMAP安装请参照《实战 linux 下 mysql+apache+php+gd 的安装和配置》
  本文参照:      
http://5iqiong.blog.运维网.com/2999926/807697但原文有一个非常重要的地方没有指出,
   第二:本例操作环境
  所使用的系统环境为 Centos 5.6 64位操作系统         cacti 的 Version 0.8.8a    Squid Cache: Version 2.7.STABLE9
  # uname -a      
Linux jedy.com 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 2011 x86_64 x86_64 x86_64 GNU/Linux      
# more /etc/redhat-release      
CentOS Linux release 6.0 (Final)
  
# /usr/local/squid/sbin/squid –v               \\ squid 安装时编辑的参数,确保其中有 --enable-snmp      
Squid Cache: Version 2.7.STABLE9      
configure options:'--prefix=/usr/local/squid' '--enable-dlmalloc' '--enable-snmp' '--with-pthreads' '--enable-epoll' '--disable-internal-dns' '--enable-removal-policies=heap,lru' '--enable-delay-pools' '--enable-storeio=aufs,coss,diskd,ufs,null' '--with-maxfd=65535'      
#
   第三:修改配置文件 (在被监控的squid服务器上)
  # cat /etc/squid/squid.conf                   \\ 确保squid文件有以下内容。      
acl CactiServer src192.168.10.22                                  \\ cacti 服务器的地址      
acl SNMP snmp_community test                                    \\ snmp 团体名      
snmp_port 3401                                                               \\ squid使用的 snmp 使用的端口      
snmp_access allow SNMP CactiServer                           \\ 允许cacti服务器连接 3401端口      
snmp_access deny all
  
#      
#vim /etc/snmp/snmpd.conf         \\ 网上说要增加下面两行,好像我没加 也能取到值,呵呵 当然最好还是加一下啦
view    systemview    included   .1.3.6.1.4.1.3495.1      
proxy -m /usr/local/squid/share/mib.txt -v 1 -c test 127.0.0.1:3401.1.3.6.1.4.1.3495.1
  
# services snmpd restart            \\ 重启服务      
# services squid restart                \\ 重启服务      
# netstat –antp | grep 3401      \\ 检查3401端口有没有起来 端口有可能没有起来
   第四:测试 (在cacti服务器上)
  # snmpwalk –Cc -v 1 -c test 192.168.10.21:3401 .1.3.6.1.4.1.3495.1       \\ 如果出现很多数据说明能取到 squid的值      
Error: OID not increasing: SNMPv2-SMI::enterprises.3495.1.5.1.1.1.      \\ 如果上面没加上 –Cc 参数 会报此错误
   第五:在cacti上配置监控 (此部分我只对重要的地方做一个说明,如果不会,请参考前言部分的链接)
   1、在cacti中导入模板            
在网上下载cacti监控模版:squidstats-0.1.zip 这个网上很多,解压后把以下文件拷贝到此目录 /resource/snmp_queries:      
webcache_squid_core.xml      
webcache_squid_median.xml      
然后在cacti中导入squid模块:      
点击”console”---->“Import Templates”,选择cacti_host_template_webcache_squid_server_snmp.xml 这个文件导入。
   2、在cacti中建立squid监控项
  
此处注意:         
Host Template 选择WebCache-Squid Server(SNMP)            
Downed Device Detection只能选ping,具体的ping的类型最好选 icmp ping,
在SNMP Options 中将SNMP port 端口 改成 3401,SNMP Community 是之前设置的比如我的 是test,默认是public       
http://jedy82.blog.运维网.com/attachment/201205/29/425872_1338256493iAxB.png
      以下是内容是WebCache-Squid Server(SNMP)模板默认的,也可在Graph Temlates中自行增加模板或是在Data Query中增加其它的squid项(注意要勾选squid version),如下:
  http://jedy82.blog.运维网.com/attachment/201205/29/425872_13382564948doU.png
       以下项要特别注意:网上很多资料没有提到,很容被忽视:
  之后每处的SNMP Community 都要写之前设置的 snmp团体名,此处我的是 test默认是snmppublic 显然不对,如果不改 那肯定取不到数据,以下以增加 squid statistic - core 为例:
  http://jedy82.blog.运维网.com/attachment/201205/29/425872_1338256495YcUE.png
  后面的步骤就很简单了。此处就不多说了



页: [1]
查看完整版本: 配置cacti 监控squid