当前位置: > Linux服务器 > 监控工具 >

cacti监控系统之一 cacti,snmp安装

时间:2014-08-28 19:23来源:linux.it.net.cn 作者:it

说明:
Cacti通过 snmpget来获取数据,使用 RRDtool绘画图形,是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。

实现:
1.yum安装LAMP,lnmp编统安装可以参考“CentOS(x64)编译安装LNMP”

# yum -y install httpd mysql-server php php-mysql mysql-devel
# chkconfig httpd on  //设置httpd开机启动
# chkconfig mysqld on
# /etc/init.d/httpd start  //启动httpd
# /etc/init.d/mysqld start

安装完成后,可通过以下程序测试

# cat index.php //内容如下
<?php
phpinfo();
?>

 
2.获取cacti及其配套软件获取

# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
Rrdtool    http://oss.oetiker.ch/rrdtool/

# wget http://sourceforge.net/projects/net-snmp/files/net-snmp/5.6.2/net-snmp-5.6.2.tar.gz
Net-snmp   http://www.net-snmp.org/

# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
Cacti      http://www.cacti.net/

 
3.安装rrdtool

# yum -y install cairo-devel libxml2-devel pango-devel  //Rrdtool安装需要cairo、libxml2、pango库支持,可通过yum安装
# tar zxvf 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/

 
4.安装net-snmp

# tar zxvf net-snmp-5.6.2.tar.gz
# cd net-snmp-5.6.1.1
# ./configure --prefix=/usr/local/net-snmp
./configure编译时,遇到checking for file... no configure: error: file program not found although it is needed by libtool,直接yum install -y file就可以了
# make && make install
# cp EXAMPLE.conf /etc/snmpd.conf
# ln -s /usr/local/net-snmp/bin/* /usr/local/bin/
# vim /etc/snmpd.conf
rocommunity public localhost //去掉注释
# /usr/local/net-snmp/sbin/snmpd -c /etc/snmpd.conf
# echo "/usr/local/net-snmp/sbin/snmpd -c /etc/snmpd.conf " >>/etc/rc.local  //加入开机启动

 
5.安装cacti

# tar zxvf cacti-0.8.8a.tar.gz
# mv cacti-0.8.8a/* /var/www/html/  //将cacti中的内容移到 web目录
# chown -R apache:apache /var/www/html/
# mysql -uroot -p  //连接到mysql创建数据库
> create database cacti;  //创建cacti数据库
> insert into mysql.user(host,user,password) values ('localhost','cacti',password('cacti123'));
//建立用户cacti,密码cacti123
> flush privileges;  //重载mysql授权表
> grant all on cacti.* to cacti@'localhost' identified by 'cacti123';  //把数据库cacti授权于用户cacti
# cd /var/www/html/
# mysql -ucacti -pcacti123 cacti<cacti.sql //将cacti数据库导入
# vim include/config.php  //修改网站连接数据库的配置文件
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti123";
$database_port = "3306";
$url_path = "/cacti/";为$url_path = "/";  //更改usr_path,不然访问cacti时地址还得加http://192.168.0.2/cacti

 
使用浏览器打开http://192.168.02/会看到安装向导,点下两个NEXT之后,出现以下:



6.默认用户admin,密码为cacti
忘记cacti登录密码可以参看:cacti忘记登录密码

(责任编辑:IT)
------分隔线----------------------------