we23213 发表于 2014-11-17 13:54:14

Linux下使用Cacti监控流量状况

    Cacti 在英文中的意思是仙人掌的意思,Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具,使用PHP开发,它是由一些PHP页面组成软件,主要针对企业的大量网络设备、服务器主机***能监测服务,可提供对CPU负载、内存占用、运行进程数、磁盘空间、网卡流量等各种数据信息的监测,cacti注重的是状态监控,报警和服务恢复功能比较差。
官方站点:
http://www.cacti.net
下载页面:
http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz



开始Cacti安装部署
机器IP地址:192.168.1219.129

软件下载:
# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz

安装lamp环境:
# yum install -y httpd mysqlmysql-server php php-mysql php-json php-pdo

安装相关的lib库:
# yum install -y cairo-devel libxml2-devel pango pango-devel

安装编译器:
# yum -y install gcc make gcc-c++

解压编译软件:
# tar -xzf rrdtool-1.4.5.tar.gz
# cd rrdtool-1.4.5
# ./configure --prefix=/usr/local/rrdtool/
# make && make install
# ln -s /usr/local/rrdtool/bin/* /usr/local/bin/

安装snmp服务:
# yum -y install net-snmp net-snmp-utils

安装Cacti主程序:
# tar xzf cacti-0.8.8a.tar.gz && mv cacti-0.8.8a /var/www/html/cacti

创建Cacti数据库:
# service mysqld start
# /usr/bin/mysqladmin -u root -h rhel64 password '123456'
# /usr/bin/mysqladmin -u root password '123456'
# mysql -uroot -p
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cacti.* to cacti@'localhost' identified by "123456";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>


把Cacti数据导入Cacti数据库:
# mysql -ucacti -p123456 cacti# chmod -R 777 /var/www/html/cacti/rra
# chmod -R 777 /var/www/html/cacti/log
# vi /var/www/html/cacti/include/config.php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2012 The Cacti Group                                 |
|                                                                         |
| This program is free software; you can redistribute it and/or         |
| modify it under the terms of the GNU General Public License             |
| as published by the Free Software Foundation; either version 2          |
| of the License, or (at your option) any later version.                  |
|                                                                         |
| This program is distributed in the hope that it will be useful,         |
| but WITHOUT ANY WARRANTY; without even the implied warranty of          |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the         |
| GNU General Public License for more details.                            |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution                     |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See|
| about.php and/or the AUTHORS file for specific developer information.   |
+-------------------------------------------------------------------------+
| http://www.cacti.net/                                                   |
+-------------------------------------------------------------------------+
*/

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "123456";
$database_port = "3306";
$database_ssl = false;

/*
   Edit this to point to the default URL of your Cacti install
   ex: if your cacti install as at http://serverip/cacti/ this
   would be set to /cacti/
*/
//$url_path = "/cacti/";

/* Default session name - Session name must contain alpha characters */
//$cacti_session_name = "Cacti";

?>

# setenforce 0
# crontab -e
*/5* * * * /usr/bin/php /var/www/html/cacti/poller.php >>/tmp/cacti_rrdtool.log 2>&1

http://192.168.1219.129/cacti/

一直点击next下去即可,用户名和密码默认是admin.admin,第一次登陆需要修改密码。
















定义监控哪些设备:
控制面版-->建立设备-->定义设备-->为设备生成图像-->在图像树中添加新设备
console-->Devices-->add(左上角)-->define devices-->Create Graphs for this Host-->create
在被监控客户机上要安装net-snmp,41行那里要填写监控端的IP地址。
# yum -y install net-snmp
# vim /etc/snmp/snmpd.conf
62 accessnotConfigGroup ""      any       noauth    exactall none none
41 com2sec notConfigUser192.168.1219.129       public
85 view all    included.1                               80

# service snmpd start


页: [1]
查看完整版本: Linux下使用Cacti监控流量状况