前面写到了cacti的基本安装与配置,接下来我们对cacti进行扩展。

1、安装MIBS库文件

   这个和snmp监控有着密切的关系,对于Ubuntu 12.04来说,默认snmp是没有启用的,你需要安装MIBS,对于Centos来说,基本不需要操心这个。

   sudo apt-get install snmp-mibs-downloader

   启用mibs,编辑/etc/snmp/snmp.conf,注释掉最后一行即可    #mibs;

   /etc/init.d/snmpd restart    //重启snmp服务

   snmpwalk -v 2c -c public localhost    //验证是否安装mibs

   经过安装发现原系统提供的snmpd.conf配置文件提供采取的信息不全,你在执行snmpwalk这条命令后发现最后一行显示类似于这种信息HOST-RESOURCES-MIB::.....No more variables left in this MIB View...,我们需要更改/etc/snmp/snmpd.conf这个配置文件,清空配置文件添加如下内容:

   #        sec.name        source          community

   com2sec  notConfigUser   127.0.0.1       public

   #        groupName       securityModel   sercurityName

   group    notConfigGroup  v1              notConfigUser

   group    notConfigGroup  v2              cnotConfigUser

   #        name            included        subtreemask(optional)

   view     systemview      included        .1.3.6.1.2.1.1

   view     systemview      included        .1.3.6.1.2.1.25.1.1

   #        group           context         sec.model               sec.level    prefix    read    write    notif

   access   notConfigGroup  ""              any                     noauth       exact     all     none     none

   #        incl/excl       subtree         mask

   view all included        .1              80


   syslocation Unknown (edit /etc/snmp/snmpd.conf)

   syscontact Root <root@localhost>(configure /etc/snmp/snmp.local.conf)

   dontLogTCPWrappersConnects yes


   /etc/init.d/snmpd restart    //重启snmpd服务


2、安装cacti插件

   thold:阈值告警,你可以对流量,CPU利用率等设备信息设置阈值告警,超过或者低于设定的阈值就会有提示或者邮件告警

   monitor:监控网络节点,哪里PING不通了会出来声音告警

   settings:配置cacti用,有些插件会调用


   1).安装方法:

       tar fxvz thold.tar.gz -C /var/www/cacti/plugins

       tar fxvz monitor.tar.gz -C /var/www/cacti/plugins

       tar fxvz settings.tar.gz -C /var/www/cacti/plugins

       导入插件数据到数据库:

       mysql -ucacti -p cacti < /var/www/cacti/plugins/monitor/monitor.sql    //如果不导入数据,在界面中看不到monitor工具按钮

       mysql -ucacti -p cacti < /var/www/cacti/plugins/thold/thold.sql

       打开cacti界面,在插件管理中安装并激活插件即可

183427542.jpg

   2).使用Npc插件整合nagios

       tar fxvz npc.tar.gz -C /var/www/cacti/plugins

       查看http://ip/cacti,在插件管理中安装并激活插件

       在此Npc安装完成,此时这个插件并无任何作用,需要安装nagios配合使用

   3).安装nagios

       sudo apt-get install nagios3

       nagios默认账户是nagiosadmin,密码在nagios安装的时候会提示输入

184148528.jpg

   4).安装ndoutils

       这个工具会将nagios的配置及监控信息存储到数据库里,Npc通过调用ndo所存储的数据来展现nagios信息

       sudo apt-get install ndoutils-nagios3-mysql

       安装完这个工具后这个服务是无法启动的,但是会提示你更改哪里的配置文件,配置文件位置为/etc/default/ndoutils

       ENABLE_NDOUTILS=1

   5).修改配置文件

       /etc/nagios3/ndo2db.cfg

       这个文件是用cacti在mysql中使用的用户和密码以及数据库,远程数据库的话应正确指定数据库IP,以及用户名账号权限

       修改内容如下:

       socket_type=tcp

       socket_name=/var/cache/nagios/ndo.sock

       db_name=cacti

       db_prefix=npc_

       db_user=cacti

       db_pass=admin


       /etc/nagios3/ndomod.cfg

       output_type=tcpsocket

       ouput=127.0.0.1

       buffer_file=/var/cache/nagios3/ndomod.tmp


       /etc/nagios3/nagios.cfg

       在251行添加如下内容

       broker_module=/usr/lib/ndoutils/ndomod-mysql-3x.o config_file=/etc/nagios3/ndomod.cfg


       service ndoutils restart

       service nagios3 restart

   6).设置参数

185739496.jpg


至此已成功配置完成!

190035154.jpg


总结:如果按照之前一篇文章和现在这篇文章安装部署,基本没什么问题了,我在中间遗留了两个问题没有说出来,我发的最后一张图是把那个问题解决了才能正确看到那些信息,看看大家能不能发现吧!


交流群:374506612