172.25.85.2 server2.example.com
172.25.85.3 server3.example.com 被监控端
关闭ipyables和selinux.
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。
cacti是用php语言实现的一个软件,它的主要功能是用snmp服务获取数据,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。因此,snmp和rrdtool是cacti的关键。Snmp关系着数据的收集,rrdtool关系着数据存储和图表的生成。snmp抓到数据不是存储在mysql中,而是存在rrdtool生成的rrd文件中(在cacti根目录的rra文件夹下)。rrdtool对数据的更 新和存储就是对rrd文件的处理,rrd文件是大小固定的档案文件(Round Robin Archive),它能够存储的数据笔数在创建时就已经定义.
1.server2:
tar zxf cacti-0.8.8h.tar.gz -C /var/www/html/
cd /var/www/html/
ln -s cacti-0.8.8h/ cacti
安装rrdtool和snmp支持工具,以及lamp:
yum install -y net-snmp rrdtool php php-gd php-dom php-mysql php-snmp net-snmp-utils
yum install -y php-snmp-5.3.3-26.el6.x86_64.rpm
vim /etc/php.ini
date.timezone = Asia/Shanghai
yum install mysql-server -y
/etc/init.d/mysqld start
mysql_secure_installation
cd /var/www/html/cacti
cat cacti.sql
mysql -predhat
mysql> create database cacti; mysql> grant all on cacti.* to cacti@localhost identified by ‘redhat‘;
mysql -ucacti -predhat cacti
mysql -ucacti -predhat cacti < cacti.sql ##倒入数据库
mysql -ucacti -predhat cacti
mysql> show tables;
vim /var/www/html/cacti/include/config.php
##修改数据库的用户和密码
cd /var/www/html/cacti
useradd -u 1000 cacti
su - cacti
crontab -e
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1 ##配置计划任务
logout
/etc/init.d/httpd start
在网页中输入:172.25.85.2/cacti/install
##设置cacti时用到的命令路径
##用户 admin 密码 admin 。第一次登陆需要修改密码。
server3:
yum install net-snmp net-snmp-utils -y
/etc/init.d/snmpd start
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex ##测试net-snmp
vim /etc/snmp/snmpd.conf
#com2sec notConfigUser default public com2sec local localhost public com2sec mynetwork 172.25.85.0/24 public group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 view all included .1 80 #access notConfigGroup "" any noauth exact systemview none none access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none syslocation rhel6.5 syscontact Root <weijing001@westos.org>
/etc/init.d/snmpd restart
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
server2:
snmpwalk -v 1 -c public 172.25.85.3 IP-MIB::ipAdEntIfIndex
server3:
vim /etc/snmp/snmpd.conf
disk / 10000
/etc/init.d/snmpd reload
scp /etc/snmp/snmpd.conf 172.25.85.2:/etc/snmp/
server2:
snmpwalk -v 1 172.25.85.3 -c public .1.3.6.1.4.1.2021.9
/etc/init.d/snmpd restart
snmpwalk -v 1 localhost -c public IP-MIB::ipAdEntIfIndex
http://172.25.85.2/cacti/host.php?action=edit&id=2
Device ->create
Graph Tress -> Default Tree ->Tree Items ->Add
server2:
rrdtool info server3_mem_free_16.rrd |less
Data Sources -> server3-Partition-/dev/mapper/Vol -> Turn On Data Source Debug Mode.
2.server2:
##安装cacti-spine
tar zxf cacti-spine-0.8.8h.tar.gz
yum install mysql-devel net-snmp-devel openssl-devel -y
yum install dos2unix autoconf automake binutils libtool gcc cpp glibc-headers kernel-headers glibc-devel -y
cd /root/cacti-spine-0.8.8h
sh bootstrap
./configure
make
make install
cd /usr/local/spine/etc/
cp spine.conf.dist /etc/spine.conf
vim /etc/spine.conf
su - cacti
/usr/local/spine/bin/spine
172.25.85.2/cacti
setting -> Poller -> save
->paths
cd /var/www/html/cacti/log
cat cacti.log
tar zxf monitor-v1.3-1.tgz -C /var/www/html/cacti/plugins
Plugin Management -> 点击下载 -> 进入monitor
Settints-Misc
原文地址:http://11713145.blog.51cto.com/11703145/1834137