yum install httpd php php-mysql php-snmp mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel
service httpd start
service mysqld start

安装rrtools

yum localinstall rrdt* --nogpgcheck

拆解 cacti的数据包

将cacti 搬移致/var/www/html

tar -zxvf cacti-0.8.7g.tar.gz -C /var/www/html
cd /var/www/html
mv cacti-0.8.7g/ cacti
# mysqld_safe --user=mysql &
# mysqladmin –u root -p password

配置mysql

CREATE DATABASE cacti;

//若只监控本机,这句就够了

grant all privileges on cacti.* to cacti@localhost identified by 'cacti';

#grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti';

//否则,要在那台服务器上的mysql中授权允许cacti主机的连接

grant Process,Super on *.* to 'cacti'@'172.16.1.6' identified by 'cacti';
#grant Process,Super on *.* to 'cacti'@'monitor.cactimon.com' identified by 'cacti';
flush privileges;

实验过程中,很多人出现graps下为空表,或无表,大多是因为这里未正确授权,导致无法连接到数据库造成的,可以用以下命令测试是否可以正常连接

mysql -h 192.168.0.1 -ucacti -pcacti

# use mysql;
# 直接插入
# insert into user(Host,User,Password) values ('172.16.1.6','cacti','cacti');
# 更新
# update user set host='monitor.cactimon.com' where host='172.16.1.6';
# update user set password=password('cacti') where host='monitor.cactimon.com';
# 删除
# delete from user where user='cacti';

cacti 网页默认登陆密码:admin admin

无法登陆:

mysql>use cacti;
mysql>update user_auth set password=md5("新密码") where username='admin';

clip_p_w_picpath002

clip_p_w_picpath003

################################

创建账号

useradd cacti -p cacti

改变权限

cd /var/www/html/cacti/

chown -R cacti rra log

配置snmp

62 access notConfigGroup "" any noauth exact all none none
85 view all included .1 80

编辑 crontab -e //每5分钟采集一次数据

*/5 * * * * php /var/www/html/cacti/poller.php >/dev/null 2>&1

导入数据库

mysql -ucacti -pcacti cacti </var/www/html/cacti/cacti.sql

编辑cacti的配置脚本

vim /var/www/html/cacti/include/config.php

clip_p_w_picpath004

http://cacti地址/cacti

p_w_picpath

p_w_picpath

安装插件管理器

tar -zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
cp -R cacti-plugin-arch/* /var/www/html/cacti/
进入控制台,对管理员启用插件管理器
进入cacti的目录
cd /var/www/html/cacti/
mysql -ucacti -pcacti cacti &lt;pa.sql
有些人老是补丁打不上,此处必须在 cacti/目录下
patch -p1 -N &lt;cacti-plugin-0.8.7g-PA-v2.8.diff
网页无图片,或无法显示,编辑php的配置文件,修改路径
vim /var/www/html/cacti/include/config.php
42 $url_path = "/cacti/";
拆解插件
tar -zxvf monitor-latest.tgz
tar -zxvf settings-latest.tgz
tar -zxvf thold-latest.tgz
安装插件
mv monitor-0.9/ /var/www/html/cacti/plugins/monitor
mv thold-0.41/ /var/www/html/cacti/plugins/thod
mv settings-0.6/ /var/www/html/cacti/plugins/settings

到控制台中启用插件 Utilities下 User Management > admin &gt;Realm Permissions &gt;Plugin Management &gt;save

p_w_picpath

Configureation下 Plugin Management &gt;Actions 下Install Plugin(蓝色向下的箭头) &gt;Enable Plugin(绿色向右的箭头)

clip_p_w_picpath006

监控mysql

# tar xvfz mysql-cacti-templates-1.1.2.tar.gz
# cp cacti-templates-1.1.2/scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/

修改脚本文件

# vim /var/www/html/cacti/scripts/ss_get_mysql_stats.php
43 $mysql_user = ¨cacti¨;
44 $mysql_pass = ¨cacti¨;
45 $mysql_port = 3306;
49 $cache_dir = ¨/var/www/html/cacti/cache¨;
# mkdir /var/www/html/cacti/cache
#chown cacti:cacti /var/www/html/cacti/cache
#chmod 777 /var/www/html/cacti/cache

导入模版

Import Templates &gt;浏览&gt; templates/cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml&gt;Import

p_w_picpath

clip_p_w_picpath007

Devices 》add》 》Create Graphs for this Host

clip_p_w_picpath009

##################################################

email

settings&gt;mail/dns &gt;send a test mail

clip_p_w_picpath011

告警邮件

clip_p_w_picpath013

Down机邮件

clip_p_w_picpath015

clip_p_w_picpath017

msn通知(昨天的聊天记录):

clip_p_w_picpath019

短信报警:

p_w_picpath