1.安装net-snmp
yum -y install net-snmp net-snmp-libs net-snmp-utils
2.配置net-snmp
vim /etc/snmpd.conf
view systemview included .1.3.6.1.2.1.1 修改为
view systemview included .1.3.6.1.2.1.
3启动snmp
service snmpd start
4.安装rrdtool
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
tar -xzf rrdtool-1.4.7.tar.gz
cd rrdtool-1.4.7
./configure --prefix=/usr/local/
如果报错lib*,则需要安装如下
yum -y install pango*
然后在执行./configure --prefix=/usr/local/
然后执行make && make install
如果执行make的过程中报错,则需要安装如下包
yum -y install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
5.下载并安装cacti
wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
tar -xzf cacti-0.8.8b.tar.gz
cd cacti-0.8.8b
mv -f * /var/www/html/cacti
6.进入数据库并创建cacti库
/usr/mysql/bin/mysql -p
create dadtabase cacti;
grant all on cacti.* to cacti@’%’identified by ‘cacti’;
7.导入cacti.sql
use cacti;
source cacti.sql;
如果报ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘TYPE=MyISAM‘ at line
则需要编辑cacti.sql修改TYPE=MyISAM,产生此报错的原因是cacti.sql是在mysql5.1部署的,而我安装的是高版本的mysql5.6所以需要进行下面的修改
vim cacti.sql
:%s/TYPE=MyISAM/ENGINE=MyISAM/g 替换并保存
然后在执行导入cacti.sql
8.配置include/config.php和include/global.php
vim include/config.php
$database_type = "mysql"; $database_default = "cacti"; $database_hostname = "127.0.0.1"; $database_username = "cacti"; $database_password = "cacti"; $database_port = "3306";
vim include/global.php
/* Default database settings*/ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "127.0.0.1"; $database_username = "cacti"; $database_password = "cacti"; $database_port = "3306";
9.设置rra目录权限
chmod -R 777 rra
10.执行看是否正常
php /var/www/html/cacti/poller.php
11.加入定时任务
*/1 * * * * /usr/local/php/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
12.打开浏览器输入http://ip/cacti进行安装和初始化
默认密码为admin,第一次需要重置密码
13.配置被监控端
首先安装SNMP服务
yum -y install net-snmp net-snmp-libs net-snmp-utils
配置snmp
vim /etc/snmp/snmpd.conf
修改如下配置
com2sec mynetwork ip/24 COMMUNITY //改成监控端的ip或者ip段
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc //去掉此注释
#以下为访问项目,如果想监控磁盘空间,load等需把注释去掉
# Make sure mountd is running
proc mountd #去掉前面的"#"
# Make sure there are no more than 4 ntalkds running, but 0 is ok too.
proc ntalkd 4
# Make sure at least one sendmail, but less than or equal to 10 are running.
proc sendmail 10 1
# Check the / partition and make sure it contains at least 10 megs.
disk / 10000
# Check for loads:
load 12 14 14
保存并重启snmpd服务
service snmpd restar
本文出自 “大花猫博客” 博客,请务必保留此出处http://bighuamao.blog.51cto.com/1995527/1633866
原文地址:http://bighuamao.blog.51cto.com/1995527/1633866