文章目录
展开
Cacti简介
cacti是用php语言实现的一个软件,它的主要功能是用snmp服务获取数据,snmp需要的变量数据是通过读取mysql数据库得到,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。rrdtool对数据的更新和存储就是对rrd文件的处理,rrd文件是大小固定的档案文件,它能够存储的数据笔数在创建时就已经定义。
SNMP用来收集数据
Rrdtool用来存储数据和生成图表
MySQL用来配合PHP程序存储一些变量数据并对变量数据进行调用。
LAMP环境
参考《lnmp、lamp、lnmpa一键安装包》
Caccti安装及配置
- #!/bin/bash
- #by LinuxEye
- #BLOG: https://linuxeye.com
- yum -y install cairo-devel libxml2-devel pango pango-devel net-snmp*
- cd /root/cacti
- tar xzf rrdtool-1.4.7.tar.gz
- cd rrdtool-1.4.7
- ./configure –prefix=/usr/local/rrdtool
- make && make install
- ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
- cd ../
- cat >> /etc/snmp/snmpd.conf << EOF
- com2sec local 127.0.0.1 public
- com2sec local 192.168.22.0/24 public
- group MyROGroup v1 local
- group MyROGroup v2c local
- group MyROGroup usm local
- view all included .1 80
- access MyROGroup “” any noauth exact all none nones
- yslocation (/etc/snmpd/snmpd.conf)
- syscontact Root <lj2007331@gmail.com>
- EOF
- tar xzf cacti-0.8.7i.tar.gz
- mv cacti-0.8.7i /usr/local/apache/htdocs/
- /usr/local/mysql/bin/mysql -uroot -padmin -e “create database cacti;”
- /usr/local/mysql/bin/mysql -uroot -padmin -e “grant all privileges on cacti.* to cacti@’localhost’ identified by ‘cacti123’ with grant option;”
- /usr/local/mysql/bin/mysql -uroot -padmin -e “flush privileges;”
- /usr/local/mysql/bin/mysql -ucacti -pcacti123 –database cacti < /usr/local/apache/htdocs/cacti/cacti.sql
- sed -i ‘s@$database_username =.*$@$database_username = “cacti”;@g’ /usr/local/apache/htdocs/cacti/include/config.php
- sed -i ‘s@$database_password =.*$@$database_password = “cacti123”;@g’ /usr/local/apache/htdocs/cacti/include/config.php
- tar xzf cacti-spine-0.8.7i.tar.gz
- cd cacti-spine-0.8.7i
- ./configure –prefix=/usr/local/spine –with-mysql=/usr/local/mysql –with-snmp=/usr/local/net-snmp
- make && make install
- mv /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
- sed -i ‘s@DB_User cactiuser@DB_User cacti@g’ /usr/local/spine/etc/spine.conf
- sed -i ‘s@DB_Pass cactiuser@DB_Pass cacti123@g’ /usr/local/spine/etc/spine.conf
#Console>Settings>Poller>PollerType,有两个选项:cmd.php和spine,选择[spine]。Console -> Configuration ->Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path,将“/usr/local/spine/bin/spine”填入文本框,选择spine是为了加快速度,cmd.php是一个php写的调度程序,而
spine是用C写的,spine的性能远远优于cmd.php,当监控的设备有很多时,cmd.php的性能就跟不上