天天看点

49.cacti监控工具

<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 &amp;&amp; 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&gt; CREATE DATABASE cacti DEFAULT CHARACTER SET utf8;

Mysql&gt;GRANT all ON cacti.* TO 'cacti'@'localhost' identified by '123';

mysql&gt; quit;

# mysql -u cacti -p cacti &lt; /var/www/html/cacti/cacti.sql

注:Mysql  -u 用户名 -p 库名或表名 &lt; /备份路径/文件名:恢复操作

# 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"

&lt;Directory "/var/www/html/cacti"&gt;

    Options None

    AllowOverride None

    Order allow,deny

    Allow from all

&lt;/Directory&gt;

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 &gt;/dev/null

本文转自   触动的风   51CTO博客,原文链接:http://blog.51cto.com/10978134/1945788