Cacti是通过 snmpget来获取数据,使用 RRDtool绘画图形,而且你完全可以不需要了解RRDtool复杂的参数。它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结构、host以及任何一张图,还可以与LDAP结合进行用户验证,同时也能自己增加模板,功能非常强大完善。
一、安装
1安装LAMP环境
#yum install -y httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server mysql-sevel
#service httpd start
#chkconfig httpd on
#service mysqld start
#chkconfig mysqld on
#mysqladmin -u root password 'password'
二、安装配置net-snmp
1安装net-snmp组件
#yum install -y net-snmp net-snmp-utils net-snmp-libs net-snmp-devel
2配置文件
#vim /etc/snmp/snmpd.conf
access not ConfigGroup "" any noauth exact systemview none none(改为)
access notConfigGroup "" any noauth exact all none none
view all included .1 80
三、安装rrdtool
#yum install -y rrdtool
四、下载安装cacti
#wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
#tar -zxvf cacti-0.8.8b.tar.gz
#mv cacti-0.8.8b /var/www/html/cacti
#cd /var/www/html/cacti/
五、配置数据库
1创建数据库
mysql>create database cacti;
2创建用户授权
mysql> GRANT ALL ON cacti.* to cacti@localhost IDENTIFIED BY 'cacti';
mysql>flush privileges;
3导入数据库
#mysqldump -ucacti -p cacti < cacti.sql
六、修改配置文件
#vim /var/www/html/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;
$url_path = "/cacti/";(取消注释)
#chown -R apache /var/www/html/cacti
七、配置计划任务
#echo "*/5 * * * * root php /var/www/html/cacti/poller.php > /dev/null 2>&1" >> /etc/crontab
#service crond restart
八、完成安装cacti
http://ip/cacti
客户端只需要配置net-snmp的community与服务器端一直即可,见步骤二
九、Cacti 优化之spine轮询器
出于效率原因,在大量采集数据时使用自带的cmd.php轮询器会比较慢,1分钟1次的采集频率可能无法完成轮询所有机器。为了优化,采用官方推荐的spine来高效轮询。下载的版本是spine-0.8.8b,所用cacti为0.8.8b。
1安装依赖包
#yum install -y mysql-devel net-snmp-devel mysql openssl-devel
2安装spine
#tar xf cacti-spine-0.8.8b.tar.gz
#cd cacti-spine-0.8.8b
#./configure
#make&&make install
3配置文件修改
#cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
#vim /usr/local/spine/etc/spine.conf
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass cacti
DB_Port 3306
DB_PreG 0
4在cacti里设置spine路径
Console -> Configuration -> Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path
输入spine路径:/usr/local/spine/bin/spine
5修改cacti使用的Poller Type
Console -> Cacti Settings->Poller->Poller Type
将Poller Type选择为spine
本文出自 “不莱梅乐队” 博客,谢绝转载!