1、Cacti簡介
cacti是用php語言實現的一個軟件,它的主要功能是用snmp服務獲取數據,snmp需要的變量數據是通過讀取mysql
數據庫得到,然後用rrdtool儲存和更新數據,當用戶需要查看數據的時候用rrdtool生成圖表呈現給用戶。rrdtool對數據的更新和存儲就是對rrd文件的處理,rrd文件是大小固定的檔案文件,它能夠存儲的數據筆數在創建時就已經定義。
1) Snmp用來收集數據;
2) Rrdtool用來存儲數據和生成圖表;
3) Mysql用來配合PHP程序存儲一些變量數據並對變量數據進行調用。
2、
LAMP環境
參考http://www.linuxeye.com/program/313.html
3、Caccti安裝及配置
#!/bin/bash
#by LinuxEye
#BLOG: http://blog.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 <[email protected]>
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>Poller Type,有兩個選項: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的性能就跟不上!