centos4.7 + cacti监控配置

author:skate
time:2009-5-20


 

centos4.7 +cacti监控配置

 

最近在配置一套监控系统,cacti+nagios

 

CACTI: 的确是一款很友好的软件,可以很直观的查看主机的性能负载,磁盘利用率,
       网络流量等情况,但唯一遗憾就是不能实现对关键服务或进程进行监控的功能
       这个东东配置起来,还是比较容易的,只要参考官文文档,安装很顺利。

 

本机需要的组件的版本:

 

[root@dbolap ~]# rpm -qa |grep httpd
httpd-2.0.52-41.ent.2.centos4

[root@dbolap ~]# rpm -qa |grep php
php-4.3.9-3.22.15
php-snmp-4.3.9-3.22.15
php-mysql-4.3.9-3.22.15

[root@dbolap ~]# rpm -qa |grep mysql
mysql-4.1.22-2.el4
mysql-server-4.1.22-2.el4

root@dbolap ~]# rpm -qa |grep net-snmp
net-snmp-libs-5.1.2-13.el4_7.3
net-snmp-5.1.2-13.el4_7.3
net-snmp-utils-5.1.2-13.el4_7.3
net-snmp-devel-5.1.2-13.el4_7.3
net-snmp-libs-5.1.2-13.el4_7.3
net-snmp-perl-5.1.2-13.el4_7.3

 

 

Cacti requires that the following software is installed on your system.

 

1. RRDTool 1.0.49 or 1.2.x or greater

2. MySQL 4.1.x or 5.x or greater

3. PHP 4.3.6 or greater, 5.x greater highly recommended for advanced features

4. A Web Server e.g. Apache or IIS


操作步骤:


1. Required Packages for RPM-based Operating Systems
2. Ports for FreeBSD
3. Configure PHP
4. Configure the Webserver (Apache)
5. Configure MySQL
6. Install and Configure Cacti
7. (Optional) Install and Configure Spine
8. Apply Patches

 

 

一。系统需要安装的组件(Required Packages for RPM-based Operating Systems)


httpd

php

php-mysql

php-snmp

mysql

mysql-server

net-snmp


因为我用的是centos,所以安装这些组件很简单,只要yum就可以了

在安装之前先检查这些组件是否已经被安装到系统上了
eg:
root> rpm -qa | grep httpd

 

安装:
root> yum install httpd
root> yum install php
root> yum install php-mysql
root> yum install php-snmp
root> yum install mysql
root> yum install mysql-server
root> yum install net-snmp

 

二。Ports for FreeBSD

 

1. www/apache2

2. net/rrdtool

3. net/net-snmp

4. www/php4-cgi

5. lang/php4 (With MySQL and SNMP Support)

6. databases/mysql323-server

 

三。Configure PHP

 

Please find the file /etc/php.ini and make the following changes to it:

extension_dir = /etc/php.dThis will enable PHP to find more configuration directives in that very directory.

Activate the MySQL extension via /etc/php.d/mysql.ini

; Enable mysql extension module
extension=mysql.soActivate the SNMP extension via /etc/php.d/snmp.ini

; Enable snmp extension module
extension=snmp.soIf using PHP 4.3.5 or less include the following line. If using 4.3.6 or greater, you should remove this line if present.

session.save_path=/tmpIf you want to allow template importing, uncomment the following line:

file_uploads = On


四。Configure the Webserver (Apache)

 

一般就需要修改,我就没有做任何修改;如果要修改,请按如下修改:


If you are using Apache 1.3.x, installation of PHP 5 is not recommended.

Please find the file /etc/httpd/conf/httpd.conf or equivalent and make the following changes to it:

# Load config files from the config directory "/etc/httpd/conf.d".
Include conf.d/*.confNow, please locate the PHP configuration file at /etc/httpd/conf.d/php.conf

If using PHP 5, then add the following lines.

# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
DirectoryIndex index.php

 

五。Configure MySQL

 

Set a password for the root user

shell> mysqladmin --user=root password somepassword
shell> mysqladmin --user=root --password reload


六。Install and Configure Cacti


Extract the distribution tarball.

 

shell> tar xzvf cacti-version.tar.gzCreate the MySQL database:

shell> mysqladmin --user=root create cactiImport the default cacti database:

shell> mysql cacti < cacti.sqlOptional: Create a MySQL username and password for Cacti.

shell> mysql --user=root mysql


mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

 

 

Edit include/config.php and specify the database type, name, host, user and password for your Cacti configuration.

 

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";

 

Set the appropriate permissions on cacti's directories for graph/log

generation. You should execute these commands from inside cacti's directory to change the permissions.

 

shell> chown -R cactiuser rra/ log/

 

 

(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering.)

Add a line to your /etc/crontab file similar to:

 

*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1

 

Replace cactiuser with the valid user specified in the previous step.

 

Replace /var/www/html/cacti/ with your full Cacti path.

 

Point your web browser to:

 

http://your-server/cacti/

 

 

Log in the with a username/password of admin. You will be required to change this password immediately. Make sure to fill in all of the path variables carefully and correctly on the following screen.


七。(Optional) Install and Configure Spine


Spine is a very fast poller engine, written in C. It is an optional replacement for cmd.php. If you decide to use it, you will have to install it explicitely. It does not come with cacti itself.

The easiest way is to install Spine using rpm or ports. You will find packages for Spine at the main cacti site or from your distribution.

To compile Spine, please download it to any location of your liking. Then, please issue from the downloaded directory following commands

 

shell>aclocal

shell>libtoolize --force  (glibtoolize --force on Max OS)shell>autoheader

shell>autoconf

shell>automake

shell>./configure

shell>make

shell>make install

 

Assuming, you've managed to install Spine correctly, you will have to configure it. The configuration file may be placed in the same directory as Spine itself or at /etc/Spine.conf.

 

 

DB_Host 127.0.0.1 or hostname (not localhost)
DB_Database cacti
DB_User  cactiuser
DB_Password cacti
DB_Port  3306All other pre 0.8.6 settings are obsolete.

 


按着如上的文档配置,一般是不会有问题的,都会成功
配置很简单, 关键是如何使用

 

---end---

 

 

参考文档如下:

 

CACTI官方安装文档
http://www.cacti.net/downloads/docs/html/index.html


http://gzmaster.blog.51cto.com/299556/72099

mysql使用
http://www.yesky.com/187/1754687_3.shtml

cacti的使用
http://blog.sina.com.cn/s/blog_4e424e2101000b6o.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值