编译安装cacti
#原有php没有启用snmp 所以先启用
yum install net-snmp-devel net-snmp-utils -y
#进入php源码目录
cd /usr/local/src/php/src/php-5.2.17/ext/snmp
./configure --with-php-config=/usr/local/php1/bin/php-config make && make install#编辑php.ini 加入
extension = "snmp.so"#重启php-fpm
/usr/local/php1/sbin/php-fpm restart
#安装cacit
1、安装rrdtools
cd /opt/src wget yum install pango-devel tar xvf rrdtool-1.4.5.tar.gz cd rrdtool-1.4.5 ./configure --prefix=/opt/rrdtool make && make install #让rrdtool支持中文显示 vi src/rrd_graph.c 在原来setlocale(LC_CTYPE,"")的位置增加以下内容setlocale(LC_ALL,"zh_CN.gb2312");
2、安装spine
wget cd /opt/src tar xvf cacti-spine-0.8.7h.tar.gz cd cacti-spine-0.8.7h ./configure --prefix=/opt/spine make && make install修改spine配置文件
cd /opt/spine/etc cp spine.conf.dist spine.conf vi spine.conf DB_Host localhost DB_Database cacti DB_User cacti DB_Pass cactiuser DB_Port 3306 DB_PreG 03、安装cacti
建立用户
useradd cacti cd /opt/src tar xvf cacti-0.8.7h.tar.gz mv cacti-0.8.7h /home/www/cacti chown -R root:root /home/www/cacti 修改配置文件(按实际信息修改) vi home/www/cacti/include/config.php$database_type = "mysql";
$database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactiuser"; $database_port = "3306"; $database_ssl = false;#创建一个数据库并导入数据
/usr/local/mysql/bin/mysql -u root -p mysql> create database cacti; mysql> grant all privileges on cacti.* to identified by "cactiuser"; mysql> flush privileges; /usr/local/mysql/bin/mysql -u root -p cacti < /home/www/cacti/cacti.sql cd /home/www/cacti chown -R cacti rra/ log/按实际路径设置
默认用户名和密码 admin
定时执行
yum install vixie-cron
crontab -u cacti -e */1 * * * * /usr/local/php1/bin/php /home/www/cacti/poller.php > /dev/null 2>&1 注意:如果在path中 提示找不到路径的话 检查php.ini 是否设置了open_basedir故障排除
无数据检查过程 检查是否有数据返回 snmpwalk -v 2c -c public 10.0.2.88 if rrdtool 是否有数据 /opt/rrdtool/bin/rrdtool fetch 13.rrd AVERAGE 还有就是要注意选择的模板是否正确