首页 > 代码库 > 49.cacti监控工具

49.cacti监控工具

cacti监控工具

Cacti是一款使用PHP语言开发的性能与流量监测工具,实际上cacti是一款web界面的管理工具,通过调用net-SNMP工具来采集检测数据,并结合RRDtool工具记录数据并绘制图片。 

监控端搭建cacti步骤:

部署LAMP平台

# yum -y install zlib freetype libjpeg fontconfig gd libxml2 php-gd

# yum -y install httpd  mysql mysql-server mysql-devel  php  php-mysql

安装net-SNMPRRDtool等软件

# 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

部署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

访问cacti网页,初始化cacti 

被控端配置

# 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所有的查询

使用Cacti采集被监控端信息

#/usr/bin/php  /var/www/html/cacti/poller.php

设置定时计划,每5分钟采集一次

#crontab -u cacti -e

内容:

*/5**** /usr/bin/php  /var/www/html/cacti/poller.php >/dev/null


49.cacti监控工具