1.安装依赖包
yum -y install net-snmp-devel mysql mysql-devel openssl-devel libtool
2.安装RRDTool
yum -y install rrdtool
3.安装snmp
yum -y install net-snmp net-snmp-utils
4.安装LAMP
yum -y install httpd mysql-server php php-mysql
service httpd start
service mysql start
5.安装cacti
下载:
wget http://www.cacti.net/downloads/cacti-0.8.8h.tar.gz
tar xf cacti-0.8.8h.tar.gz
创建账号:
useradd -m cacti
passwd cacti
初始化数据库:
create user 'cacti'@'localhost' identified by 'cacti';
create database cacti;
grant all on cacti.* to 'cacti'@'localhost';
cd cacti-0.8.8h
mysql -uroot -p cacti < cacti.sql 如果没有密码,直接回车
创建rrd账号
useradd cactiuser
mv cacti-0.8.8h /var/www/html/cacti
cd /var/www/html/cacti
chown -R cactiuser rra log
*/ * * * * root /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 加入/etc/crontab
出现时间安全问题,修改php.ini
date.timezone = Asia/Shanghai 去掉注释病修改
6.配置cacti
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 = "";
$database_ssl = false;
7.增加spine,优化的轮询
wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
tar -xvf cacti-spine-0.8.8a.tar.gz
cd cacti-spine-0.8.8a
./configure
make && make install 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
B_Pass cacti
DB_Port
DB_PreG 0
测试和数据库是否可以通信
配置cacti使用spine轮询
查看日志
tail -f /var/www/html/cacti/log/cacti.log
轮询方法由cmd.php改变为spine
常见问题
没有数据:
查看tail -f /var/www/html/cacti/log/cacti.log是否每隔5分钟出现日志,如果没有检查定时任务
如果crontab不支持,使用脚本
[root@monitor shell]# cat /root/shell/foreach_cacti.sh
#!/bin/bash
(while true;
do
/usr/bin/php /var/www/html/cacti/poller.php > /dev/null;
sleep ;
done) &