- 1、编辑/etc/yum.repo.d/Centos.Base.repo文件,把下面内容加入最后:
- [dag]
- name=Dag RPM Repository for Red Hat Enterprise Linux
- baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
- gpgcheck=1
- gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
- enabled=1
- 2、# yum clean all
- # yum install rrdtool rrdtool-devel rrdtool-php
- com2secnotConfigUser default public中default该用来127.0.0.1
- access notConfigGroup "" any noauth exact systemview none none将systemview该为all
- #view all included .1 80的‘#’去掉
- #service snmpd restart
#tar xvf cacti-0.8.7e.tar.gz
#mv cacti-o.8.73.tar.gz /var/www/html/cacti
#useradd cacti
#chown –R cacti /var/www/html/cacti
#chmod -R 775 /var/www/html/cacti
在数据库中配置cacti的访问权限:
- mysql> create database cacti;
- mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option;
- mysql> grant all privileges on cacti.* to [email protected] identified by 'cacti' with grant option;
- mysql> use cacti;
- mysql> source /var/www/html/cacti/cacti.sql;配置/var/www/html/cacti/include/config.php ,将username,password该一下
- #service httpd restart
创建个计划任务:crontab –u cacti –e 加入下列内容:
确保:/var/www/html/cacti/rra存在,如果没有看到图可以手动执行一下这个计划中的命令
- # service mysqld restart
选择default trees-----单击default trees---add 填入一下内容即可,然后选择graphs可以看着监控的主机的图
- # tar xvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
- # cp -R cacti-plugin-arch/* /var/www/html/cacti/cd /var/www/html/cacti/
- #mysql -ucacti -pcacti cacti <pa.sqlpatch -p1 -N <cacti-plugin-0.8.7g-PA-v2.8.diff
- # 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 settings-0.6/ /var/www/html/cacti/plugins/settings
- # mv thold-0.41/ /var/www/html/cacti/plugins/thold登陆安装启用对应的插件即可。
- [Thu Feb 09 15:12:24 2006] [error] [client 127.0.0.1] File does not exist: /var/www/html/favicon.ico
- ERROR: opening '/var/www/html/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied
- # snmpwalk -c public -v 2c 127.0.0.1
- IF-MIB::ifHCInOctetsIF-MIB::ifHCInOctets.1 = Counter64: 7437357IF-MIB::ifHCInOctets.2 = Counter64: 353773IF-MIB::ifHCInOctets.3 = Counter64: 0
- wget http://mysql-cacti-templates.googlecode.com/files/mysql-cacti-templates-1.1.2.tar.gz
- tar -xzvf mysql-cacti-templates-1.1.2.tar.gz
- cd mysql-cacti-templates-1.1.2
- cp ss_get_mysql_stats.php /var/www/html/cacti/scripts
- $mysql_user = 'cacti';
- $mysql_pass = 'cacti';
- $cache_dir = "var/www/html/cacti/cache/";
- #mkdir /var/www/html/cacti/cacti/cache/
- #chmod 777 -R /var/www/html/cacti/cache/
- mysql> grant process,super on *.* to 'cacti'@'%' identified by 'cacti';
- mysql> grant all privileges on cacti.* to cacti@"%" identified by "cacti";
网卡流量的监控:
- 编辑:/etc/snmpd/snmpd.conf文件:
- view systemview included .1.3.6.1.2.1.1
- view systemview included .1.3.6.1.2.1.25.1.1
- view systemview included .1.3.6.1.2.1.2
- 说明:如果要监控流量的话,需要在监控端把标红的(第三行)内容加入snmpd.conf文件中
之后,在host-templates设置如下图,Interface-Traffic(流量)、其他的是主机监控(测试过)
最后在devices中添加主机,在Graph Trees中设置,等个N分钟就会出现如下内容:
关于绘图:cmd.php是最低是5分钟采集一次数据的,效率比较低(没有测试);而spine最低可以降到每1分钟采集数据而且配置主机到显示图等的时间并不长:
- #tar xvf cacti-spine-0.8.7e.tar.gz
- #cd cacti-spine-0.8.7e
- #./configure --prefix=/usr/local/spine --with-snmp=/usr --with-mysql=/usr/local/mysql/
- #make
- #make install
- # ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
- 编辑spine.conf文件,将数据库名等信息填写对;测试是否能用:/usr/local/spine/bin/spine
- 如果出现:SPINE: Poller[0] FATAL: Unable to read configuration file! (Spine init),数目你的spine.conf文件有问题,重新编译安装; 如果一直出现该问题是因为版本太低,把/usr/local/spine/etc/spine.conf 复制到/etc/spine.conf ,再次测试即可:看到有starting字符,就是成功
可能出现的问题:我出现过这么个问题:Cannot find SNMP header files under yes 对这个问题一致很纳闷,net-snmp-devel也安装了,最后发现必须使用--with-snmp=/usr,如果不加路径的话,会一直出现该问题的。