<b>cacti監控工具</b>
Cacti是一款使用PHP語言開發的性能與流量監測工具,實際上cacti是一款web界面的管理工具,通過調用net-SNMP工具來采集檢測資料,并結合RRDtool工具記錄資料并繪制圖檔。
監控端搭建cacti步驟:
v 部署LAMP平台
# yum -y install zlib freetype libjpeg fontconfig gd libxml2 php-gd
# yum -y install httpd mysql mysql-server mysql-devel php php-mysql
v 安裝net-SNMP,RRDtool等軟體
# yum -y install net-snmp net-snmp-utils
#service snmpd restart
# tar xzvf rrdtool-1.4.8.tar.gz
# cd rrdtool-1.4.8
# yum -y install cairo-devel zlib libxml2 libxml2-devel glib2 glib2-devel libpng libpng-devel freetype freetype-devel libart_lgpl pango pango-devel pear pear-devel perl-CPAN
#./configure --prefix=/usr/local/rrdtools
#make && make install
v 部署cacti,設定資料庫連接配接
# tar xzvf cacti-0.8.8b.tar.gz
# mv cacti-0.8.8b /var/www/html/cacti
#useradd cacti
# chown -R cacti.cacti /var/www/html/cacti/
#service mysqld restart
#mysqladmin -u root password ‘123’
#mysql -u root -p123
mysql> CREATE DATABASE cacti DEFAULT CHARACTER SET utf8;
Mysql>GRANT all ON cacti.* TO 'cacti'@'localhost' identified by '123';
mysql> quit;
# mysql -u cacti -p cacti < /var/www/html/cacti/cacti.sql
注:Mysql -u 使用者名 -p 庫名或表名 < /備份路徑/檔案名:恢複操作
# vim /var/www/html/cacti/include/config.php
修改相關内容:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "123";
$database_port = "3306";
$database_ssl = false;
# vim /etc/httpd/conf/httpd.conf
修改相關參數:
ServerName www.example.com:80
DocumentRoot "/var/www/html/cacti"
<Directory "/var/www/html/cacti">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php index.html index.html.var
v 通路cacti網頁,初始化cacti
v 被控端配置
# yum -y install net-snmp lm_sensors
#vim /etc/snmp/snmpd.conf
修改内容:
com2sec notConfigUser 1.1.1.130 public
access notConfigGroup "" any noauth exact all none none
view all included .1 80
#service snmpd restart
注:修改的第一行表示:允許誰來監控我,設定相應的cacti監控端位址
修改的第二行表示:all表示開放所有的SNMP查詢權限(預設是systemview)
修改的第三行表示:.1表示SNMP所有的查詢
v 使用Cacti采集被監控端資訊
#/usr/bin/php /var/www/html/cacti/poller.php
v 設定定時計劃,每5分鐘采集一次
#crontab -u cacti -e
内容:
*/5**** /usr/bin/php /var/www/html/cacti/poller.php >/dev/null
本文轉自 觸動的風 51CTO部落格,原文連結:http://blog.51cto.com/10978134/1945788