一、阐述

Cacti是一套基于ApacheMySQLPHP环境,结合SNMP,RRDTool开发的网络流量监测图形分析工具,Cacti的实现原理是通过Snmp服务获取数据,然后用rrdtool存储和更新数据,当用户通过IEFirefox浏览器查看图形数据的时候,rrdtoo通过自身的绘图功能生成图表展现给用户,如下图:

服务器流量、性能监控之Cacti

图片google中截图

因此在构建Cacti监控时,snmprrdtool是关键,snmp关系着数据的收集,rrdtool关系着数据的存储和图表的生成。


二、应用环境

1>系统版本

[[email protected]_Server ~]# lsb_release -d

Description:    CentOS release 5.8 (Final)


2>系统架构

[[email protected]_Server ~]# uname -m

x86_64


3>内核版本

[[email protected]_Server ~]# uname -r

2.6.18-308.el5


4>系统环境

[[email protected]_Server ~]# dmidecode -s system-product-name

VMware Virtual Platform //VMware虚拟机


三、软件资源下载列表

LAMP环境资源下载:

Apache官方网站:http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.23.tar.gz

MySQL搜狐镜像: http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.70.tar.gz

PHP官方网站:http://www.php.net/get/php-5.5.0.tar.gz/from/ar2.php.net/mirror

PHP IConv库:

提供字符集转换功能http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz


Cacti官方下载地址如下:

Cactihttp://www.cacti.net/downloads/cacti-0.8.8a.tar.gz

Spine(轮训器)http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz

RRDTool(绘图软件) http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

Cacti插件下载地址:

http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz

http://docs.cacti.net/_media/plugin:ntop-v0.2-1.tgz

http://docs.cacti.net/_media/plugin:thold-v0.5.0.tgz

http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz



提示:

之前写的一篇博文http://cfwlxf.blog.51cto.com/3966339/1247649,详细的撰写Apache的安装、配置、优化以及对网页数据传输压缩模块的支持,对Dos/DDos***的防御,文档并未涉及MySQLPHP的安装与优化,如此便在写Cacti的安装之前先搭建LAMP环境,介绍ApacheMySQLPHP的安装,关于软件资源的下载地址,上述已提供。


1、软件资源下载:

#创建存放下载资源的目录,方便后期统一管理

[[email protected]_Server cacti]# mkdir /downsource/{lamp,cacti} -pv

mkdir: created directory `/downsource'

mkdir: created directory `/downsource/lamp'

mkdir: created directory `/downsource/cacti'

关于参数的详解:

-p:表示递归创建目录,即便同时创建多个。

-v:提示用户创建的结果


12 通过Wget方式下载LAMP环境所需的资源

[[email protected]_Server cacti]# cd /downsource/lamp/#切换目录,存放LAMP资源

[[email protected]_Server lamp]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.23.tar.gz

--2013-06-18 00:16:08--  http://apache.etoak.com/httpd/httpd-2.2.24.tar.gz

Resolving apache.etoak.com... 60.215.129.67

Connecting to apache.etoak.com|60.215.129.67|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 7385376 (7.0M) [application/x-gzip]

Saving to: `httpd-2.2.24.tar.gz'


100%[======================================>] 7,385,376   90.6K/s   in 61s    

2013-06-18 00:17:09 (118 KB/s) - `httpd-2.2.24.tar.gz' saved [7385376/7385376]


13 通过Wget方式下载Cacti所需的资源

[[email protected]_Server ~]# cd /downsource/cacti/#存放Cacti资源的目录

[[email protected]_Server cacti]# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz

Cacti£ohttp://www.cacti.net/downloads/cacti-0.8.8a.tar.gz: Unsupported scheme.

[[email protected]_Server cacti]# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz      

--2013-06-18 00:54:01--  http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz

Resolving www.cacti.net... 209.242.232.5, 140.211.167.231, 173.225.179.10

Connecting to www.cacti.net|209.242.232.5|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 2273280 (2.2M) [application/x-gzip]

Saving to: `cacti-0.8.8a.tar.gz'


100%[=====================================>] 2,273,280   37.2K/s   in 35s    


2013-06-18 00:54:38 (63.3 KB/s) - `cacti-0.8.8a.tar.gz' saved [2273280/2273280]

备注:

后续的所有软件都是通过Wget的方式,在线下载。如果你的VM虚拟机并不能提供上网的功能,便无法使用Wget下载软件;即便如此你还可以先把软件下载至本地,然后通过secureCRT软件自带的上传/下载功能,上传至服务器中,此方法上篇文档已做详细的介绍,这里不再累赘;请参考http://cfwlxf.blog.51cto.com/3966339/1247649


2、LAMP环境的安装

21 Web服务Apache的安装

提示:

在执行./configure会启用Apache可移植的运行库apr的功能,此库需要apr-develapr-util-devel库的支持,预先需要先安装apr库,避免出现提示apr的错误;安装方式如下:


#检测系统是否安装apr-develapr-util-devel程序包

[[email protected]_Server httpd-2.2.23]# rpm -qa | egrep 'apr-devel|apr-util-devel'

apr-util-devel-1.2.7-11.el5_5.2

apr-util-devel-1.2.7-11.el5_5.2

apr-devel-1.2.7-11.el5_6.5

apr-devel-1.2.7-11.el5_6.5

#没有安装的话,在执行如下命令

[[email protected]_Server httpd-2.2.23]# yum install apr-util-devel apr-devel -y


22 安装

[[email protected]_Server lamp]# tar -xf httpd-2.2.23.tar.gz #解压软件

[[email protected]_Server lamp]# cd httpd-2.2.23             #切换目录

[[email protected]_Server httpd-2.2.23]# ./configure --prefix=/application/apache2.2.23 --enable-deflate --enable-login --enable-expires --enable-static-support --enable-http --enable-info --enable-rewrite --enable-so --with-mpm=worker --enable-mods-shared=most --with-included-apr

提示:关于各参数的提供的功能,这里不做解释,请参考之前我写的一篇文档:http://cfwlxf.blog.51cto.com/3966339/1247649


[[email protected]_Server httpd-2.2.23]# make#编译

[[email protected]_Server httpd-2.2.23]# make install #编译安装


#为应用程序目录建立软连接,方便将来程序升级

[[email protected]_Server httpd-2.2.23]# ln -s /application/apache2.2.23/ /application/apache


#授予用户apache管理web服务

[[email protected]_Server php-5.5.0]# #修改用户为apache

sed -i 's/User daemon/User apache/g' /application/apache/conf/httpd.conf


[[email protected]_Server php-5.5.0]# #修改用户组为apche

sed -i 's/Group daemon/Group apache/g' /application/apache/conf/httpd.conf        


#查询修改结果

[[email protected]_Server php-5.5.0]# egrep 'User|Group' /application/apache/conf/httpd.conf

# User/Group: The name (or #number) of the user/group to run httpd as.

User apache

Group apache


#授予apache管理Apache服务

[[email protected]_Server php-5.5.0]# chown -R apache.apache /application/apache/


23 运行Web服务

[[email protected]_Server httpd-2.2.23]# /application/apache/bin/apachectl -t        #检测语法

httpd: apr_sockaddr_info_get() failed for Web_Server

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Syntax OK

#提示:语法是没有错误的,可以忽略提示,如果使你感觉不美观的话,你可以根据apr_sockaddr_info_get()提示,修改ServerName127.0.0.1,本机的IP地址192.168.10.171也可以,操作如下:

[[email protected]_Server httpd-2.2.23]# sed -i 's/#ServerName www.example.com:80/ServerName 192.168.10.171:80/g' /application/apache/conf/httpd.conf    #服务器名字为本地IP地址


[[email protected]_Server httpd-2.2.23]# grep ServerName /application/apache/conf/httpd.conf                                                 # ServerName gives the name and port that the server uses to identify itself.

ServerName 192.168.10.171:80    #查询修改的结果

[

[email protected]_Server httpd-2.2.23]# /application/apache/bin/apachectl -t                                                                Syntax OK    

#提示已经没有了


[[email protected]_Server httpd-2.2.23]# /application/apache/bin/apachectl start    #运行Web服务

[[email protected]_Server httpd-2.2.23]# netstat -lntp | grep httpd

tcp        0      0 :::80                       :::*                        LISTEN      29850/httpd


[[email protected]_Server httpd-2.2.23]# curl -I http://192.168.10.171    #通过crul的方式验证

HTTP/1.1 200 OK

Date: Mon, 17 Jun 2013 18:03:46 GMT

Server: Apache/2.2.23 (Unix) DAV/2

Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT

ETag: "86965-2c-3e9564c23b600"

Accept-Ranges: bytes

Content-Length: 44

Content-Type: text/html


24 MySQL安装

[[email protected]_Server lamp]#tar -xf mysql-5.1.70.tar.gz     #解压软件

[[email protected]_Server lamp]# cd mysql-5.1.70        #切换目录

[[email protected]_Server mysql-5.1.70]# ./configure

--prefix=/application/mysql-5.1.70 \             #指定MySQL程序的安装目录

--enable-local-infile\                        #**MySQL加载本地数据的支持

--with-extra-charsets=complex\            #**MySQL支持扩展的字符集

--with-pthread \                        #强制使用pthread(posix线程库)

--with-mysqld-user=mysql \            #指定管理MySQL程序的用户

--with-big-tables \                #支持大的数据表格式

--with-plugins=innobase \        #支持MySQL插件innobase

--with-embedded-server \        #构建嵌入式服务器libmysqld

--with-server-suffix \        #支持版本字符串

--enable-assembler \        #允许使用汇编模式

--with-unix-socket-path=/application/mysql-5.1.70/tmp/mysql.sock \       #指定unix套接字的路径

--datadir=/application/mysql-5.1.70/data \        #指定MySQL数据安装目录

--with-client-ldflags=-all-static \        #以纯静态方式编译客户端

--with-mysqld-ldflags=-all-static \        #以纯静态方式编译服务端


[[email protected]_Server mysql-5.1.70]# make#编译

[[email protected]_Server mysql-5.1.70]# make install#编译安装

提示:执行./confingure时,会检测系统当前的环境,是否安装编译工具,系统的字符等,并生成MakeFile文件,make会依据MakeFile文件中程序,执行相应的编译操作,make install 参照编译过的Make文件,执行安装动作。


#拷贝MySQL的配置文件至/etc/目录下,并命名为my.cnf

[[email protected]_Server mysql-5.1.70]# cp support-files/my-medium.cnf /etc/my.cnf


#拷贝MySQL的运行脚本至/etc/init.d/目录下,并命名为mysqld

[[email protected]_Server mysql-5.1.70]# cp support-files/mysql.server /etc/init.d/mysqld


#赋予mysqld执行权限

[[email protected]_Server mysql-5.1.70]# chmod 755 /etc/init.d/mysqld


#创建MySQL用户和组

[[email protected]_Server mysql-5.1.70]# groupadd mysql

[[email protected]_Server mysql-5.1.70]# useradd -s /sbin/nologin -g mysql mysql


#生成mysql用户数据库和表文件

[[email protected]_Server mysql-5.1.70]# /application/mysql-5.1.70/bin/mysql_install_db --user=mysql


#运行MySQL数据库服务

[[email protected]_Server mysql-5.1.70]# /etc/init.d/mysqld start

Starting MySQL.                                            [  OK  ]


#检查MySQL监听端口

[[email protected]_Server ~]# netstat -lnpt | grep 3306

tcp        0      0 0.0.0.0:3306      0.0.0.0:*      LISTEN      8232/mysqld


#设置登陆MySQL数据的密码

[[email protected]_Server mysql-5.1.70]# /application/mysql-5.1.70/bin/mysqladmin -uroot password '123456'


#通过命令行的形式,查看Mysql中所有的数据库。

[[email protected]_Server mysql-5.1.70]# /application/mysql-5.1.70/bin/mysql -uroot -p123456 -e 'show databases;'

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

参数:

-e:执行,通过Linux命令行,执行MySQL命令。


#MySQL安装程序建立软连接,方便将来程序升级

[[email protected]_Server lamp]# ln -s /application/mysql-5.1.70/ /application/mysql

[[email protected]_Server lamp]# ll /application/

Total8

lrwxrwxrwx  1 root  root    26 06-18 01:51 apache -> /application/apache2.2.23/

drwxr-xr-x 15 root  root  4096 06-18 01:25 apache2.2.23

lrwxrwxrwx  1 root  root    26 06-18 03:24 mysql -> /application/mysql-5.1.70/

drwxr-xr-x 12 mysql mysql 4096 06-18 03:02 mysql-5.1.70



25 PHP安装

2.5.1 安装Iconv插件,让PHP支持字符集的转换功能

[[email protected]_Server libiconv-1.14]# tar -xf libiconv-1.14.tar.gz    #解压程序

[[email protected]_Server libiconv-1.14]# cd libiconv-1.14     #切换目录

[[email protected]_Server libiconv-1.14]# ./configure --prefix=/usr/local/iconv    #指定安装目录

[[email protected]_Server libiconv-1.14]# make        #编译

[[email protected]_Server libiconv-1.14]# make install        #编译安装


2.5.2 编译PHP

[[email protected]_Server lamp]# tar -xf php-5.5.0.tar.gz        #加压缩

[[email protected]_Server lamp]# cd php-5.5.0        #切换目录

[[email protected]_Server php-5.5.0]# ./configure

--prefix=/application/php-5.5.0 \        #指定PHP程序安装目录

--with-config-file-path=/application/php-5.5.0/etc/ \    #指定PHP配置文件安装路径(php.ini

#执定MySQL的安装路径,为了让PHP支持MySQL

--with-mysql=/application/mysql-5.1.70/ \

--enable-soap \            #**(soap)简单对象访问协议的支持

--enable-shared \            #构建共享库

--enable-static \#构建静态库

#mysqli扩展允许我们访问MySQL 4.1及以上版本提供的功能

--with-mysqli=/application/mysql-5.1.70/bin/mysql_config \

--with-pcre-dir \        #指定pcre库的安装路径支持正则表达式

--with-jpeg-dir \        #指定jpeg图片库的路径

--with-png-dir \         #指定png图片库的路径

--with-freetype-dir \    #指定freetype字体库的安装路径

--with-gd \              #指定gd库的安装路径

--with-zlib-dir \        #指定zlib库的安装路径

--with-iconv-dir=/usr/local/libiconv/ \        #指定Iconv的安装路径

提示:因使用的是系统已经编译好的rpm包安装的jpegpnggdfreetypepcre库,所以配置时并没有指定其安装路径,编译PHP时默认会自动去/usr目录下加载所需的库。

#关闭pear的库支持,类似于Perl CPAN档案的工具

--without-pear \

--enable-mbstring \            #使PHP支持多字节字符串
提示:mbstring 提供了针对多字节字符串的函数,能够帮你处理 PHP 中的多字节编码。 除此以外,mbstring 还能在可能的字符编码之间相互进行编码转换

--with-apxs2=/application/apache/bin/apxs \        #构建共享Apache 2.0处理程序模块

--enable-sockets \

提示--enable-sockets**套接字通信接口功能的支持,若你的服务器是用作监控,那么./configure时需要加上次功能,不然Cacti无法通过snmp采集数据。

--enable-gd-native-ttf \        #**TureType字体的支持


#复制PHP的配置文件并命名为php.ini

[[email protected]_Server php-5.5.0]# mkdir /application/php-5.5.0/etc     #创建存放php.ini文件的目录

[[email protected]_Server php-5.5.0]# cp php.ini-development /application/php-5.5.0/etc/php.ini

[[email protected]_Server php-5.5.0]# ll /application/php-5.5.0/etc/    #检测复制结果

Total  76

-rw-r--r-- 1 root root 70538 07-16 21:44 php.ini


#PHP程序安装目录建立软连接,方便将来版本升级

[[email protected]_Server php-5.5.0]# ln -s /application/php-5.5.0/ /application/php

[[email protected]_Server php-5.5.0]# ll /application/                              

Total 12

lrwxrwxrwx  1 root   root     26 06-18 01:51 apache -> /application/apache2.2.23/

drwxr-xr-x 15 apache apache 4096 06-18 01:25 apache2.2.23

lrwxrwxrwx  1 root   root     26 06-18 03:24 mysql -> /application/mysql-5.1.70/

drwxr-xr-x 12 mysql  mysql  4096 06-18 03:02 mysql-5.1.70

lrwxrwxrwx  1 root   root     23 07-16 21:48 php -> /application/php-5.5.0/

drwxr-xr-x  7 root   root   4096 07-16 21:44 php-5.5.0


#编辑Apache配置文件,让其能够解析PHP脚本

AddType application/x-httpd-php .php NaNhml        #大约在357行增加此参数

<IfModule dir_module>

   DirectoryIndex index.html index.php            #大约在214行增加index.php参数

</IfModule>

#关于libphp5模块就不需要自行添加了,编译PHPApache自动导入了此模块

LoadModule php5_module        modules/libphp5.so


#测试LAMP环境是否构建成功

[[email protected]_Server php-5.5.0]# /application/apache/bin/apachectl -t

Syntax OK#检测Apahce配置文件语法,建议每次配置文件更改时执行。


#重新加载配置文件,让新增加的参数生效,此命令为Apache的优雅重启,不影响正在访问的用户

[[email protected]_Server php-5.5.0]# /application/apache/bin/apachectl graceful


[[email protected]_Server php-5.5.0]# vim /application/apache/htdocs/index.php     #编写PHP测试脚本


<?php

       phpinfo();

?>


[[email protected]_Server php-5.5.0]# curl -I http://192.168.10.171/index.php        #通过Curl方式测试

HTTP/1.1 200 OK#若返回的状态码为200,则证明LAMP环境搭建成功。

Date: Tue, 16 Jul 2013 14:03:25 GMT

Server: Apache/2.2.23 (Unix) DAV/2 PHP/5.5.0

Last-Modified: Tue, 16 Jul 2013 14:02:06 GMT

ETag: "86ec9-15-4e1a16c12d380"

Accept-Ranges: bytes

Content-Length: 21

Content-Type: text/plain


#Windows端测试结果,phpinfo会详细打印出PHP支持的功能及配置参数

服务器流量、性能监控之Cacti


#提示:希望多时的配置,能有些让您欣慰的收获。


四、Cacti的安装与配置

41 安装Cacti所需的插件rrdtoolsnmp

411 编译安装rrdtool绘图软件

[[email protected]_Server rrdtool-1.4.7]# tar -xf rrdtool-1.4.7.tar.gz        #解压程序包

[[email protected]_Server rrdtool-1.4.7]# cd rrdtool-1.4.7        #切换目录

[[email protected]_Server rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool  #指定安装目录

[[email protected]_Server rrdtool-1.4.7]# make                #编译

[[email protected]_Server rrdtool-1.4.7]# make install        #编译安装

[[email protected]_Server rrdtool-1.4.7]# ll /usr/local/rrdtool/        #检验安装结果

Total 20

drwxr-xr-x 2 root root 4096 07-22 19:26 bin

drwxr-xr-x 2 root root 4096 07-22 19:26 include

drwxr-xr-x 4 root root 4096 07-22 19:26 lib

drwxr-xr-x 3 root root 4096 07-22 19:26 lib64

drwxr-xr-x 5 root root 4096 07-22 19:26 share


412 通过yum安装snmp数据采集软件

提示:先查询系统是否安装了net-snmp-develnet-snmp-libsphp-snmp

[[email protected]_Server cacti]# rpm -qa | grep net-snmp*        #发现并没有内容显示

[[email protected]_Server cacti]# yum install net-snmp-devel net-snmp-libs php-snmp net-snmp-utils -y

[[email protected]_Server cacti]# rpm -qa | grep net-snmp*        #检测安装结果

net-snmp-libs-5.3.2.2-17.el5

net-snmp-devel-5.3.2.2-17.el5

net-snmp-5.3.2.2-17.el5

net-snmp-utils.x86_64


413 启动snmp服务

[[email protected]_Server ~]# /etc/init.d/snmpd start

成功snmpd                                              [确定]

[[email protected]_Server ~]# netstat -lntp | grep snmpd

tcp        0      0 127.0.0.1:199         0.0.0.0:*       LISTEN      15618/snmpd


42 编译安装监控软件Cacti

[[email protected]_Server cacti]# tar -xf cacti-0.8.8a.tar.gz -C /application/apache/htdocs/

[[email protected]_Server cacti]# cd /application/apache/htdocs/        #切换目录

[[email protected]_Server htdocs]# mv cacti-0.8.8a/ cacti        #改名为cacti

参数:

-C:指定解压的目录,注意C是大写字母


43 登陆MySQL,创建Cacti所需的数据库

[[email protected]_Server cacti]# /application/mysql/bin/mysql -uroot -p123456        #登陆MySQL

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.1.70yes-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

#如果你想安装中文版的Cacti,创建数据库的时候可以指定类型为UTF8

mysql> create database cactidb default character set utf8;

Query OK, 1 row affected (0.00 sec)


#授予cacti用户管理cactidb数据,并拥有所有的权限。

mysql> grant all on cactidb.* to [email protected] identified by 'cactipasswd';

Query OK, 0 rows affected (0.00 sec)


#刷新MySQL权限列表

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)


#导入cacitsql文件至MySQL中的cactidb数据库

[[email protected]_Server cacti]# /application/mysql/bin/mysql -uroot -p123456 cactidb < cacti.sql


#检测cactidb数据库中是否有数据

[[email protected]_Server cacti]# /application/mysql/bin/mysql -uroot -p123456 -e 'use cactidb;show tables;'  

+---------------------------+

| Tables_in_cactidb         |

+---------------------------+

| cdef                      |

| cdef_items                |

| colors                    |

| data_input                |

| data_input_data           |

| data_input_fields         |

| data_local                |

| data_template             |


43 修改Cacti数据库配置文件config.php

$database_default = "cactidb";

$database_hostname = "192.168.10.171";
$database_username = "cacti";

$database_password = "cactipasswd";


44 通过Windows端的IE浏览器测试

服务器流量、性能监控之Cacti

提示:引起报错的原因是时区问题,解决问题的方法是需要修改php.ini文件,参数如下:date.timezone = "Asia/Shanghai"


441 重启Apache服务,让其修改的参数生效

[[email protected]_Server cacti]# /application/apache/bin/apachectl stop#        关闭Apache服务

[[email protected]_Server cacti]# /application/apache/bin/apachectl start        #开启Apache服务


45 通过Firefox浏览器执行cacti监控的安装过程,此过程中会需要你修改rrdtoolphp的安装路径

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti

提示:上例图中会告诉你数据库的名字:cactidb,管理cacti数据库的用户名:cacti,系统类型:Unix/Linux。


服务器流量、性能监控之Cacti

提示:图中红色标记是需要你修改的地方,因为安装rrdtool时,默认采用的是rpm安装的路径,而PHPRRDTool我们都是编译安装的,报错是理所当然的,所以只要把路径修改为./configure --prefix=/path指定的安装路径即可。


服务器流量、性能监控之Cacti


服务器流量、性能监控之Cacti


46 登陆cacti管理页面


服务器流量、性能监控之Cacti


开心的时候更需要努力,此时离成功还有很远,不过当您看到此界面的时候,内心中还是很喜悦的。


47 安装spine轮询引擎替代Caci默认cmd.php轮询引擎

提示:spine是一个基于C语言的开发的软件,多线程的轮询引擎。可以使用spine替代Cacti默认的cmd.php轮询引擎,这样做主要是为了加快SNMP轮训,设置一分钟轮询。当你发现你的cmd.php 运行超过300 秒的话,推荐使用Spine。


[[email protected]_Server cacti]# tar -xf cacti-spine-0.8.8a.tar.gz    #解压软件

[[email protected]_Server cacti]# cd cacti-spine-0.8.8a        #切换目录

[[email protected]_Server cacti-spine-0.8.8a]# ./configure \

--prefix=/usr/local/spine \        #指定spine轮询器安装目录

--with-mysql=/application/mysql/      #指定MySQL的安装路径

--with-snmp=/usr/            #指定net-snmp程序的include路径

[[email protected]_Server cacti-spine-0.8.8a]# make        #编译

[[email protected]_Server cacti-spine-0.8.8a]# make install         #编译安装


#切换至spine配置文件目录,将原有的配置文件复制为spine.conf

[[email protected]_Server cacti-spine-0.8.8a]# cd /usr/local/spine/etc/

[[email protected]_Server etc]# cp spine.conf.dist /etc/spine.conf


471 编辑spine配置文件,修改相应的参数值

[[email protected]_Server etc]# vim spine.conf        #编译spine配置文件

DB_Host         192.168.10.171

DB_Database     cactidb

DB_User         cacti

DB_Pass         cactipasswd

DB_Port         3306

DB_PreG         0

提示:若您是按照此文档部署的环境,那么修改参数请保持一致。如果您细心的话,会发现此时修改的参数值与之前编辑Cacti的配置文件指定的参数值是一样的。


472 测试spine

[[email protected]_Server etc]# ../bin/spine  

SPINE: Using spine config file [spine.conf]

SPINE: Version 0.8.8a starting

SPINE: Time: 0.1874 s, Threads: 5, Hosts: 2

提示:若出您执行spine操作时,屏幕上出现上述的提示,则证明spine轮询引擎已经安装成功,后续我们要做的便是通过IE/Firefox浏览器添加对应的路径即可。


48>  通过Cacti图形界面Settings选项,设置GeneralPathsPoller选择中的相关参数


服务器流量、性能监控之Cacti



服务器流量、性能监控之Cacti


4、8、1>  Paths选择设置,定义net-snmp相关命令的绝对路径,cacti字体,rrdtool数据存放路径等

服务器流量、性能监控之Cacti


4、9> Poller设置,定义轮询引擎,Poller轮询间隔时间

服务器流量、性能监控之Cacti


提示:修改之后,请保存。

五、新建cacti监控图,监控远程主机的Memor的利用率,流量图,如图所示:

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti


#提示:点击Create创建监控

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti

服务器流量、性能监控之Cacti

提示:创建后,就会有图像生成。

#此篇文档就先写到这里了,不过请放心,下篇文档会是这篇文档的续章。