1、先安装一些必要的东西
yum -y install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils cairo-devel pango-devel perl-devel perl-CPAN
2、修改文件
vim /etc/snmp/snmpd.conf
将其中62行的systemview改为all即可,并启用85行:view all included .1 80
3、启动 service snmpd start 及检测 snmpwalk -c public -v 2c localhost system
4、下在东西
wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8b.tar.gz wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.8.tar.gz
5、安装rrdtool
tar zxvf rrdtool-1.4.8.tar.gz cd rrdtool-1.4.8 ./configure --prefix=/usr/local/rrdtool make && make install ln -s /usr/local/rrdtool/bin/* /usr/sbin/
6、安装cacti-spine
tar zxvf cacti-spine-0.8.8b.tar.gz ./configure --with-mysql=/usr/ make && make install
7、安装cacti
tar zxvf cacti-0.8.8b.tar.gz mv cacti-0.8.8b /home/www/cacti/cacti
8、配置数据库
mysql > grant all on cacti.* to [email protected] identified by ‘cacti‘; mysql > flush privileges; cd /home/www/cacti/cacti mysql -ucacti -pcacti cacti < cacti.sql vi include/config.php 填写正确的数据库连接信息
9、安装cacti
用浏览器访问http://IP/cacti/install,通过向导安装cacti
10、添加定时计划
*/1 * * * * /usr/local/php/bin/php /home/www/cacti/cacti/poller.php
11、配置Spine
cd /usr/local/spine/etc/ mv spine.conf.dist spine.conf vi spine.conf DB_Host localhost DB_Database cacti DB_User cacti DB_Pass cacti DB_Port 3306
12、执行spine命令,检查是否正确
/usr/local/spine/bin/spine
如果出问题:
执行ln -sv /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib 和 ldconfig命令
13、登陆web,进入“Setting”-->“Paths”-->“Spine Poller File Path”填写:/usr/local/spine/bin/spine;并“Save”。
14、无法出图的原因
PHP Warning: exec() has been disabled for security reasons in /home/www/cacti/cacti/lib/poller.php on line 126
PHP Warning: popen() has been disabled for security reasons in /home/www/cacti/cacti/lib/rrd.php on line 52
有图无数据的原因:
ntpdate time.nist.gov
/usr/local/php/bin/php /home/www/cacti/cacti/poller.php --force检测能不能生成图象
system utilities -> Rebuild Poller Cache消除缓存一下
15、percona安装
下载http://www.percona.com/downloads/percona-monitoring-plugins/
从percona-monitoring-plugins-xx.tar.gz提取本插件安装所需内容。就MySQL监控而言,涉及到:
1)percona-monitoring-plugins-xx\cacti\scripts\ss_get_mysql_stats.php
用于获取监控数据
2)percona-monitoring-plugins-xx\cacti\templates\cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.0.2.xml
监控模板。
3) Cacti服务端操作
将percona-monitoring-plugins-1.0.2\cacti\scripts\ss_get_mysql_stats.php拷贝到Cacti服务器的/var/www/html/cacti/scripts下
4) 模板导入
通过Cacti的Web界面,console->Import/Export->Import Templates,导入1.0.2\cacti\templates\cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.0.2.xml文件