快速搭建cacti监控系统

0x01 服务器环境

OS环境:Centos 6.4_x86_64
WEB环境:nginx 、php、 mysql

0x02 Cacti架构

《快速搭建cacti监控系统》 Cacti架构

0x03 准备工作

  1. 下载相关安装包
$ wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz
$ wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
$ wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
$ wget http://jaist.dl.sourceforge.net/project/net-snmp/net-snmp/5.4.4/net-snmp-5.4.4.tar.gz
  1. 安装相关依赖包
$ yum install cairo-devel libxml2-devel pango-devel -y
  1. 安装net-snmp
$ tar zxvf net-snmp-5.4.4.tar.gz && cd net-snmp-5.4.4 && ./configure --prefix=/data/app/net-snmp && make && make install
  1. 安装rrdtool
$ tar zxvf rrdtool-1.4.7.tar.gz && cd rrdtool-1.4.7 && ./configure --prefix=/data/app/rrdtool && make && make install
  1. 创建软链接
$ ln -s /data/app/net-snmp/bin/* /usr/local/bin/
$ ln -s /data/app/rrdtool/bin/* /usr/local/bin/

0x04 安装cacti

  1. 解压cacti,并移动到web目录下
$ tar zxvf cacti-0.8.8f.tar.gz
$ mv cacti-0.8.8f /opt
  1. 建立数据库cacti,并增加对该数据库拥有所有权限的用户名cacti,该用户密码为:cacti
$ mysql> create database cacti; 
$ mysql> grant all on cacti.* to cacti@localhost identified by 'cacti';
$ mysql> grant all on cacti.* to cacti@127.0.0.1 identified by 'cacti'; 
$ mysql> flush privileges;
  1. 导入数据文件
$ mysql -ucacti -p cacti </opt/cacti/cacti.sql
  1. 修改cacti的配置脚本
$ vim /opt/cacti/include/config.php 
database_type = "mysql"; 
database_default = "cacti";
database_hostname = "localhost";
database_username = "cacti"; 
database_password = "cacti"; 
database_port = "3306"; 
database_ssl = false;
  1. 初始化cacti
    输入URL:http://ip/cacti/install/, 进入cacti欢迎安装界面
    安装完成后给rra和log两个目录赋予权限
$ chmod 777 /data/www/html/cacti/rra 
$ chmod 777 /data/www/html/cacti/log
  1. 添加定时采集任务,没五分钟采集一次
$ crontab -e 
*/5 * * * * /usr/bin/php /opt/cacti/poller.php

0x05 Q&A

  1. 安装后cacti提示RRDTool 版本不对
    原因:在php.ini中存在 disable_functions配置,默认配置中,cli执行函数都是被禁止的,需要在php.ini中将 disable_functions = exec 中的exec去掉,重启服务即可。

博客地址:http://yangfannie.com

    原文作者:聂扬帆博客
    原文地址: https://www.jianshu.com/p/1ca3e9e6c220
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞