RHEL5.4下cacti及相关插件的编译安装

一、概述

1. Cacti 是用php 语言实现的一个软件,它的主要功能是用snmp 服务获取数据,

然后用rrdtool 储存和更新数据,当用户需要查看数据的时候用rrdtool 生成图表

呈现给用户。因此,snmp 和rrdtool 是cacti 的关键。snmp 关系着数据的收集,

rrdtool 关系着数据存储和图表的生成。

2. Mysql 配合PHP 程序存储一些变量数据并对变量数据进行调用,如:主机名、主

机ip、snmp 团体名、端口号、模板信息等变量。

3. snmp 抓到数据不是存储在mysql 中,而是存在rrdtool 生成的rrd 文件中(在

cacti 根目录的rra 文件夹下)。rrdtool 对数据的更新和存储就是对rrd 文件的处

理,rrd 文件是大小固定的档案文件(Round Robin Archive),它能够存储的数据笔数

在创建时就已经定义。

二、Cacti的架构及工作流程

1. Cacti 的架构




    		    RHEL5.4下cacti及相关插件的编译安装

2. Cacti 的工作流程




    		    RHEL5.4下cacti及相关插件的编译安装

安装需求:(cacti相关包下载地址:http://www.cacti.net/downloads/)

· RRDTool 1.2.x 或者更高

· MySQL 4.1.x or 5.x 或者更高

· PHP 4.3.6 或者更高(推荐5.3以下,否则会报很多错误) php-mysql php-snmp

· Web服务 例如:Apache 或者 IIS

· net-snmp

php编译配置时需要添加下列模块:(可用php –m查看这些模块是否安装)

· mysql

· snmp

· xml

· session

· sockets

· gd (安装一些插件时需要)

· LDAP (当用LDAP认证时需要,非必须)

安装过程步骤:

1.安装必需组件

yum install –y fontconfig* autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel libart_lgpl* pango* libtool* ncurses ncurses-devel curl curl-devel openssl openssl-devel perl* net-snmp*

2. 安装mysql

查看系统中是否已经安装了MySQL,如果是卸载所有以mysql 开头的包。

yum remove –y mysql*

tar -zxvf mysql-5.1.44.tar.gz -C /usr/local/src

useradd mysql

cd /usr/local/src/mysql-5.1.44

./configure --prefix=/usr/local/cacti/mysql --enable-local-infile --with-charset=gbk

--with-low-memory --with-mysqld-user=mysql --enable-thread-safe-client

make && make install

cp /usr/local/src/mysql-5.1.44/support-files/my-medium.cnf /etc/my.cnf

chown -R mysql:mysql /usr/local/cacti/mysql/

/usr/local/cacti/mysql/bin/mysql_install_db --user=mysql

/usr/local/cacti/mysql/bin/mysqld_safe --user=mysql &

echo "/usr/local/cacti/mysql/lib/mysql" >> /etc/ld.so.conf

cp /usr/local/src/mysql-5.1.44/support-files/mysql.server /etc/init.d/mysqld

ln -s /usr/local/cacti/mysql/bin/mysql /usr/local/bin/mysql

ldconfig -v | grep mysql

chmod 755 /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

3.安装Apache

tar -zxvf httpd-2.2.15.tar.gz -C /usr/local/src

cd /usr/local/src/httpd-2.2.15

./configure --prefix=/usr/local/cacti/apache --enable-so --enable-rewrite --enable-ssl --with-ssl=/usr/bin/openssl --with-zlib --enable-mods-shared=all --enable-track-vars --with-mysql=/usr/local/cacti/mysql

make && make install

/usr/local/cacti/apache/bin/apachectl start

ln -s /usr/local/cacti/apache/bin/apachectl /etc/init.d/httpd

vi /etc/init.d/httpd //添加如下两行

#description:http server

#chkconfig: 2345 83 17

chkconfig --add httpd

chkconfig httpd on

添加php支持

vi /usr/local/cacti/apache/conf/httpd.conf

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

<IfModule dir_module>

DirectoryIndex index.php index.html

</IfModule>

4.安装php

tar -zxvf php-5.2.8tar.gz -C /usr/local/src

cd /usr/local/src/php-5.2.8

./configure --prefix=/usr/local/cacti/php --with-config-file-path=/usr/local/cacti/php

--with-apxs2=/usr/local/cacti/apache/bin/apxs --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/cacti/mysql --with-mysqli=/usr/local/cacti/mysql/bin/mysql_config --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir --enable-sockets --with-snmp

make && make install

cp php.ini-dist /usr/local/cacti/php/php.ini

ln -s /usr/local/cacti/php/bin/php /usr/bin

vim /usr/local/cacti/apache/htdocs/index.php

<?

phpinfo();

?>

5.安装rrdtool

yum install –y intltool //先更新intltool

tar -zxvf rrdtool-1.3.9.tar.gz

cd rrdtool-1.3.9

./configure --prefix=/usr/local/cacti/rrdtool

make && make install

6.安装spine

tar -zxvf cacti-spine-0.8.7e.tar.gz

cd cacti-spine-0.8.7e

./configure --prefix=/usr/local/cacti/spine --with-mysql=/usr/local/cacti/mysql

make && make install

cat /usr/local/cacti/spine/etc/spine.conf

DB_Host localhost

DB_Database cacti

DB_User cactiuser

DB_Pass cactiuser

DB_Port 3306

7.安装cacti并创建cacti数据库

tar -zxvf cacti-0.8.7e.tar.gz

mv cacti-0.8.7e /usr/local/cacti/apache/htdocs/cacti

chown –R root:root /usr/local/cacti/apache/htdocs/cacti

cat /usr/local/cacti/apache/htdocs/cacti/include/config.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cactiuser";

$database_port = "3306";

cat /usr/local/cacti/apache/htdocs/cacti/include/global.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cactiuser";

$database_port = "3306";

useradd cactiuser

/usr/local/bin/mysql

mysql> create database cacti;

mysql> grant all privileges on cacti.* to [email protected] identified by "cactiuser";

mysql>flush privileges;

mysql cacti < /usr/local/cacti/apache/htdocs/cacti/cacti.sql //导入数据库

8.定时执行

crontab -e

*/5 * * * * php /usr/local/cacti/apache/htdocs/cacti/poller.php > /dev/null 2>&1

9.在浏览器中输入http://serverIP/cacti 安装配置cacti




    		    RHEL5.4下cacti及相关插件的编译安装

设置完后用http://serverIP/cacti/登录,默认用户名和密码都是admin,第一次登录要求强制修改密码




    		    RHEL5.4下cacti及相关插件的编译安装

安装后的Settings设置,需要注意net-snmp,roodtool的版本号.spine路径,poller type,如下:




    		    RHEL5.4下cacti及相关插件的编译安装




    		    RHEL5.4下cacti及相关插件的编译安装




    		    RHEL5.4下cacti及相关插件的编译安装

以下是一些插件的安装,用于扩展功能

10.安装Plugin Architecture

unzip cacti-plugin-0.8.7e-PA-v2.5.zip

/usr/local/bin/mysql cacti < pa.sql

cp cacti-plugin-0.8.7e-PA-v2.5.diff /usr/local/cacti/apache/htdocs/cacti/

cd /usr/local/cacti/apache/htdocs/cacti/

patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5.diff

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$config['url_path']='/';改成

$config['url_path']='/cacti/';

User Management-->admin-->选中Plugin Management 保存

刷新页面,左侧configuratin的Settings下面会显示Plugin Managemnet

11.settings插件的安装

tar -zxvf settings-0.5.tgz

mv settings-0.5 /usr/local/cacti/apache/htdocs/cacti/plugins/settings

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[] = 'settings';

$plugins[] = 'weathermap';

$plugins[] = 'monitor';

$plugins[] = 'thold';

$plugins[] = 'ntop';

$plugins[] = 'syslog';

$plugins[] = 'discovery';

点击左侧--->Plugin Management-->在新打开的窗口中会显示刚安装的settings插件,如图: 


    		    RHEL5.4下cacti及相关插件的编译安装

必须Install再Enable才能使用

13.weathermap插件的安装

unzip php-weathermap-0.97.zip

mv weathermap/ /usr/local/cacti/apache/htdocs/cacti/plugins/weathermap

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[]='weathermap';

cd /usr/local/cacti/apache/htdocs/cacti/plugins/weathermap

chown cactiuser output

cp editor-config.php-dist editor-config.php

ps -aux | grep httpd

chown daemon configs/

chmod u+w configs/

vi editor-config.php

$cacti_base = "/usr/local/cacti/apache/htdocs/cacti";

$cacti_url = "http://192.168.0.161/cacti/";

$mapdir= $cacti_base.'/plugins/weathermap/configs';

$ignore_cacti = FALSE;

将editor.php中的ENABLED=false改为true,否则weathermap点击Editor时会报错

vim /usr/local/cacti/apache/htdocs/cacti/plugins/weathermap/editor.php

//$ENABLED=false; 将false改为true

$ENABLED=true;

14.monitor的安装

tar -zxvf monitor-latest.tgz

mv monitor-0.9/ /usr/local/cacti/apache/htdocs/cacti/plugins/monitor

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[]='monitor';添加

15.thold的安装

tar -zxvf thold-latest.tgz

mv thold-0.41/ /usr/local/cacti/apache/htdocs/cacti/plugins/thold

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[]='thold';添加

在Plugin Managment中,将刚安装的monitor,thold Install-->Enable 就可以看到monitor thold的标签了




    		    RHEL5.4下cacti及相关插件的编译安装

16. notp的安装

安装ntop之前要安装libpcap和rrdttool

tar -zxvf libpcap-1.1.1.tar.gz

cd libpcap-1.1.1

./configure

make && make install

tar -zxvf ntop-3.3.tar.gz

cd ntop-3.3

./autogen.sh --with-rrd-home=/usr/local/cacti/rrdtool --disable-snmp

./configure --prefix=/usr/local/ntop --with-rrd-home=/usr/local/cacti/rrdtool --disable-snmp

make && make install

cp packages/RedHat/ntop.conf.sample /etc/ntop.conf

配置ntop

groupadd ntop

useradd ntop -g ntop

mkdir /var/log/ntop

chown -R ntop.ntop /usr/local/share/ntop

chown -R ntop.ntop /var/log/ntop

mkdir /usr/local/var/ntop/rrd

chmod -R 777 /usr/local/var/ntop/rrd/

ln -s /usr/lib64/libpcap.so.0.9.4 /lib64/libpcap.so.1

ldconfig

/usr/local/ntop/bin/ntop -A

###########################################################################################

/usr/local/ntop/bin/ntop: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory

ldd /usr/local/ntop/bin/ntop

libpcap.so.1 => not found

libpcap.so.1 => not found

find / -name libpcap.so*

# find / -name libpcap.so*

/usr/local/lib/libpcap.so.1.1.1

/usr/local/lib/libpcap.so.1

/usr/local/lib/libpcap.so

/usr/local/libpcap/lib/libpcap.so.1.1.1

/usr/local/libpcap/lib/libpcap.so.1

/usr/local/libpcap/lib/libpcap.so

/usr/lib64/libpcap.so.0.9.4

/usr/lib64/libpcap.so.0

/usr/lib64/libpcap.so.0.9

ln -s /usr/lib64/libpcap.so.0.9.4 /lib64/libpcap.so.1

ldconfig

###########################################################################################

/usr/local/ntop/bin/ntop -P /var/log/ntop -u nobody & //启动服务(测试不成功)

/usr/local/ntop/bin/ntop -p /var/log/ntop //这样是成功的

设置开机自动启动:

echo "/usr/local/ntop/bin/ntop -p /var/log/ntop & 2>1 1> /dev/null" >> /etc/rc.local

配置完成.

IP输入: http://192.168.0.200:3000 就OK 了.

tar -zxvf ntop-0.1.tar.gz

mv ntop /usr/local/cacti/apache/htdocs/cacti/plugins/ntop

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[]='ntop';添加

User Management-->admin-->View NTop




    		    RHEL5.4下cacti及相关插件的编译安装

17.syslog安装,可以做为日志服务器

tar -zxvf syslog-0.5.2.tar.gz

mv syslog /usr/local/cacti/ap

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[]='syslog';添加

vim /usr/local/cacti/apache/htdocs/cacti/plugins/syslog/config.php

$syslogdb_type = 'mysql';

$syslogdb_default = 'syslog';

$syslogdb_hostname = 'localhost

$syslogdb_username = 'cactiuser';

$syslogdb_password = 'cactiuser';

//建立syslog数据库及用syslog.sql建表等

/usr/local/bin/mysql

mysql> create database syslog;

mysql> quit;

/usr/local/bin/

mysql> grant all privileges on syslog.* to [email protected] identified by "cactiuser";

mysql> flush privileges;

mysql> exit;

service syslog stop

安装rpm -ivh syslog

vi /etc/syslog-ng/syslog-ng.conf

# 在文件末尾添加如下内容

source net {

udp();

};

destionation d_mysql{

pipe("/tmp/mysql.pipe”)

template("INSERT INTO

'$FACILITY', '$PRIORITY', '$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$MSG' );\n") template-escape(yes)

);

};

log { source(net); destination(d_mysql); }

log { source(s_sys); destination(d_mysql); }

shell配置

vim /sbin/syslogtomysql

#!/bin/bash

if [ ! -e /tmp/mysql.pipe];then

mkfifo /tmp/mysql.pipe

fi

while[-e /tmp/mysql.pipe]

do

mysql –u cactiuser –password=cactiuser syslog </tmp/mysql.pipe

done

chmod 755 /sbin/syslogtomysql

echo "/sbin/syslogtomysql &" >> /etc/rc.local

/sbin/syslogtomysql &

service syslog-ng restart

service mysqld restart

chkconfig syslog off

chkconfig --del syslog

chkconfig syslon-ng on

chkconfig --add syslog-n

点击syslog标签会有php的警告信息,经查找,是syslog.php中timespan_settings.php的路径不对,怀疑是版本问题导致

vim /usr/local/cacti/apache/htdocs/cacti/plugins/syslog/syslog.php

include($syslog_config["graphtime"] ? "./lib/timespan_settings.php

"plugins/syslog/html/syslog_timespan_settings.php"); //改为上面的路/*include($syslog_config["graphtime"] ? "./include/html/inc_timespan_settings.

"plugins/syslog/html/syslog_timespan_settings.php");*/

18.discovery的安装

tar -zxvf discovery-0.8.5.tar.gz

mv discovery /usr/local/cacti/apache/htdocs/cacti/plugins/discovery

vi /usr/local/cacti/apache/htdocs/cacti/include/global.php

$plugins=array();找到这一项,添加

$plugins[]='discovery';添加

全部安装完后效果图:




    		    RHEL5.4下cacti及相关插件的编译安装

本文出自 “老林的技术笔记” 博客,请务必保留此出处http://lilinqing.blog.51cto.com/1122687/383994

更多相关文章
  • 


    		    RHEL5.4下Cacti+rrdtool+Netsnmp流量與效能監測系統安裝筆錄
    应公司新项目需求,这两天在RHEL5.4下用Cacti配置了一台流量与性能监测系统服务器,现把安装过程记录了下来,供自己和其它朋友们以后参考. 本文参考了51CTO陆文举博客中的题为<Linux下Cacti安装>的一篇文章,在此非常感谢该位作者. Cacti是一套基于PHP,MySQL, ...
  • 


    		    RHEL5.9下cacti監控的部署詳解
    cacti是一套基于php.mysql.snmp以及rrdtool开发的系统监控图形分析工具,它通过snmp来获取数据,使用rrdtool绘画图形而且完全可以不需要了解rrdtool复杂的命令参数,它提供了非常强大的数据和用户管理界面,可以指定每一个用户能查看树状结构以及主机的任何一张图,还可以与L ...
  • 首先安装基础依赖组建,注:这些依赖组建也是LINUX+PHP+MYSQL+APACHE+NGINX+MEMCACHED时必要的系统组件  LANG=C  yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-d ...
  • 


    		    cacti中cactispin插件安装
    cacti中cacti-spin插件安装 spine是一个基于C语言的,非常快速的轮询引擎.它是默认的cmd.php轮询的可选替代,当cacti监控的主机达到几十个的时候,这种采集数据延时情况就越发地显现出来. 下载并安装cacti-spine的源代码 tar xvfz cacti-spine-0. ...
  • Centos Cacti 0.8.8a 安装配置实录 说明: 1,所有加粗字体为命令,可直接复制使用: 2,本文所有操作均为笔者亲自测试成功:如有问题,欢迎随时交流Mailto:[email protected]:QQ:17118352: 3,操作系统版本:Linux RedHat Enterprise
  • CentOs 6.0 下安装cacti的syslog插件 一.软件环境: OS:CentOS 6.0 x86_64 rsyslog rsyslog-mysql syslog-v1.22-2.tgz 监控端(安装cac
  • 


    		    Linux下cacti+syslogng+snare
    Linux下cacti+syslog-ng+snare 系统环境:CentOS5.4 文档
  • 


    		    RHEL5.4下Apache+php+MySQL+Snort+acid安裝配置NIDS筆錄
    为公司信息安全要求,上周配置了一台网络入侵检测系统(NIDS),今天把安装过程记录下来,供
一周排行