cacti监控系统的配置过程

1 、安装mysql
tar �C zxvf mysql- 5.0.41 -linux-i686-icc-glibc23.tar.gz

groupadd mysql
useradd -g mysql mysql
cd /usr/local
chown -R mysql:mysql mysql
cd mysql
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
chgrp -R mysql .
cp �C a ./ mysql- 5.0.41 -linux-i686-icc-glibc23 /usr/local/mysql
cp support-files/my-medium.cnf  /etc/my.cnf
 
vi /etc/my.cnf
[mysqld]部分下添加:
datadir = /var/lib/mysql
 
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 3 mysql on
service mysql start
 
/usr/local/mysql/bin/mysqladmin �C u root password 123456

2
、安装apache

tar �Czxvf  httpd- 2.2.6 .tar.gz
c d httpd-2.2.6
./configure --prefix=/usr/local/apache2 --enable-module=so --enable-rewrite
make && make install
 
cp support/apachectl  /etc/init.d/httpd
 
vi /etc/init.d/httpd
加入:
 
# Startup script for the Apache Web Server
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd         
# pidfile: /usr/local/apache2/log/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
 
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 3 httpd on
mkdir �Cp /var/log/httpd/access_log
service httpd start
 

3
、安装php
cd php- 5.2.4
./configure \
--prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib --with-png-dir=/usr/lib \
--with-freetype-dir=/usr/include/freetype2 --with-ttf \
    --enable-sockets --enable-ftp --enable-mbstring
make && make install
# httpd配置文件里加入,使apache支持php
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
 
cp php.ini-dist /usr/local/php/php.ini
vi  /usr/local/apache2/conf/httpd.conf
加入:
###############for php and cacti###################
AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
DirectoryIndex index.php index.html index.html.var
#######################over########################

service httpd start

4
、设置mysql
 /usr/local/mysql/bin/mysql -u root �Cp123456

create database cactidb;

grant all on cactidb.* to root;


grant all on cactidb.* to root@localhost;

grant all on cactidb.* to cactiuser;

grant all on cactidb.* to cactiuser@localhost;

set password for cactiuser@localhost=password('cactipw');
exit

5
、安装rrdtool
./configure
make && make install
即可
mrtg相比,rrdtool自带了gd,所以不用先安装gd.(不过由于rrdtool自带的gd库不支持中文,所以rrdtool画出来的图也不能有中文,否则会出现乱码).

注意:rrdtool1.2的版本由于已经不再自带外部的lib库(如cgilibzlib等),所以需要从http: //people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/下载这些库来安装。建议还是使用 1.0的版本,比较方便。

6
、安装net-snmp
几乎所有的网络设备和操作系统默认都安装了snmp服务。
unix
系统安装的都是net-snmpucd-snmp(其实两个都是同一组人写的)
如果没有安装snmp,可以到net-snmp.sourceforge.org上下载源码编译安装。
我这里说的安装SNMP服务并不是要求安装SNMPD,其实是Cacti需要用到net-snmp中的两个命令�D�Dsnmpwalksnmpget进行数据的采集。

我们可以直接在系统中运行snmpwalksnmpget看是否有该命令,如果有则不用安装了。

7
、安装cacti

cp cacti-0.8.6c.tar.gz /usr/local/apache2/htdocs/
tar xzvf cacti-0.8.6c.tar.gz
mv cacti-0.8.6c cacti
cd cacti
/usr/local/mysql/bin/mysql �Cu root �Cprootroot cactidb < cacti.sql
chown �CR cactiuser rra/ log/

设置配置文件:
vi /usr/local/apache2/htdocs/cacti/include/config.php

$database_type = “mysql”;    
$database_default = “cactidb”;                  //(cacti
数据库名 )
$database_hostname = “localhost”;
$database_username = “cactiuser”;              //
cacti 数据库用户)
$database_password = “cactipw”;                // cacti数据库密码)

Crontab �Cu cactiuser �Ce
cactiuser 用户加入
*/5 * * * *  /usr/local/php/bin/php /usr/local/apache2/htdocs/cacti/poller.php >; /dev/null 2>;&1

(不要使用root用户运行上面的命令,否则要再运行一次chown �CR cactiuser rra/ log/

8
、页面设置:

在浏览器上输入:
http://IP/cacti
进入cacti的初始设置页面:
在这里我们要输入一些原始的信息:

/usr/bin/snmpwalk
/usr/bin/snmpget
/usr/bin/snmpgetnext
/usr/local/rrdtool-1.0.50/bin/rrdtool
/usr/bin/snmpbulkwalk
/usr/local/php/bin/php
/usr/local/apache2/htdocs/cacti/log/cacti.log
 
 

输入一些信息,如rrdtoolphpsnmpwalksnmpget的位置,使用ucd-snmp还是net-snmp等 -》
输入原始的用户和密码:admin/admin -》
更改admin用户的密码 -》
点击 Save

打开默认的/etc/snmp/snmpd.conf文件,更改如下配置:


1
、查找以下字段:
#       sec.name  source          community
com2sec notConfigUser  default       public

"comunity"字段改为你要设置的共同体名.比如"public".
                                               
“default”改为你想哪台机器可以看到你的snmp信息,10.10.10.10

2
、查找以下字段:
# Finally, grant the group read-only access to the systemview view.


#       group          context sec.model sec.level prefix read   write  notif
 
 
#access  notConfigGroup ""      any       noauth    exact  systemview none none
改成:

access  notConfigGroup ""      any       noauth    exact  all none none

"read"字段改为all.

3
、查找以下字段:
##           incl/excl subtree                          mask
#view all    included  .1                               80

将该行前面的"#"去掉.


保存关闭.


4
、运行/etc/init.d/snmpd start命令运行snmpd.

最后运行netstat -ln查看161端口是否打开了.



rrdtool fetch yourRRDfile.rrd AVERAGE
 
 
 
1,  首先要下载 Plugin Architecture ,这个使得 cacti 可以使用插件,目前的版本是 2.1 下载地址是 http://cactiusers.org/downloads/cacti-plugin-arch.tar.gz

tar zxvf cacti-plugin-arch.tar.gz
注意:要下与自己监控系统的版本相同的插件,否则 patch 不成功
安装:
cd cacti-plugin-arch
mv  cacti-plugin-0.8.7b-PA-v2.1.diff/usr/local/apache2/htdocs/cacti
cd /usr/local/apache2/htdocs/cacti
patch -p1 -N < cacti-plugin-0.8.7b-PA-v2.1.diff //
进行patch

配置
vi /usr/local/apache2/htdocs/cacti/include/global.php
找到 $config['url_path'] = "/";这行
如果你的 cacti安装路径是
http://servername/projects/cacti/testing/
那就需要把这个参数改成
$config['url_path'] = "/projects/cacti/testing/";
如果你的 cacti安装路径是
http://servername/cacti/
那这个参数就应该是
$config['url_path'] = "/cacti/";
 
2 ,接下来下载 Monitor 这个插件,目前最新版本 0.8.2 ,地址: http://cactiusers.org/downloads/monitor.tar.gz
tar zxvf monitor.tar.gz -C /usr/local/apache2/htdocs/cacti/plugins
解压完毕后进入到 /usr/local/apache2/htdocs/cacti/plugins/monitor 目录
执行 mysql -u root -p cactdbi <monitor.sql   //cactidb 是数据库名
然后编辑 cacti 目录下的 include/global.php 文件
$plugins = array();
找到这行,然后在他的下面添加
$plugins[] = 'monitor';
保存退出后就重启 apache 就可以看到 monitor 了。

你可能感兴趣的:(linux,职场,休闲)