Chinaunix首页 | 论坛 | 博客
  • 博客访问: 176487
  • 博文数量: 85
  • 博客积分: 1370
  • 博客等级: 中尉
  • 技术积分: 953
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-17 17:51
文章分类

全部博文(85)

文章存档

2010年(85)

我的朋友

分类: 网络与安全

2010-08-25 18:18:31

Cacti(愿意仙人掌,也是次软件的名称)实在大型网络常见的性能监测软件,可提供对CPU负载、内存占用、运行进程数、磁盘空间、网卡流量等各种数据进行监测。
Cacti本身只是基于PHP语言编写的一套管理套件,需要使用Net-SNMP工具采集监测数据,并结合RRDtool(轮询数据库工具)记录数据及绘制图片,并通过web页面的形式展现给管理员用户。
原理图;

软件获取:
clip_image001 Cacti下载
p 官方站点:
clip_image001[1] RRDTool
p Round Robin Database Tool,轮询数据库工具
p 官方站点:
需求:
Redhat 5.4或者CentOS5.5系统,采用文本安装模式最小化安装,构建YUM。
实现步骤:
一.配置被监测端(snmpd)
在被检测的linux主机中,安装好net-snmp软件包,并配置启动snmpd服务,以便允许Cacti系统采集数据。
1. 安装net-snmp软件包

net-snmp软件需要用到lm_sensors提供的硬件监测模块,安装时直接使用系统光盘中的rpm包文件,依次安装lm_sensors、 net-snmp。(被监测的服务器需要安装snmpd服务,在监测服务器上还需要安装net-snmp-utils- 5.3.2.2-7.el5.i386.rpm)

[root@www ~]# mount /dev/cdrom /media/mnt/
[root@www ~]# cd /media/mnt/Server/
[root@www Server]# rpm -ivh lm_sensors-2.10.7-4.el5.i386.rpm
[root@www Server]# rpm -ivh net-snmp-5.3.2.2-7.el5.i386.rpm
[root@www Server]# rpm -ivh net-snmp-utils-5.3.2.2-7.el5.i386.rpm
2. 配置及启动snmpd服务
修改/etc/snmp/snmpd.conf文件
修改内容:
把com2sec notConfigUser default public
access notConfigGroup "" any noauth exact systemview none none
#view all included .1 80
修改为
com2sec notConfigUser 192.168.1.111 public
access notConfigGroup "" any noauth exact all none none
view all included .1 80
3. 启动snmpd服务并设置开机启动
[root@www ~]# service snmpd start
[root@www ~]# chkconfig --level 35 snmpd on
二.配置监测服务端(Cacti)
Cacti监测服务端需要有Apache、Mysql、PHP网站平台的支持,且需要预先安装有gd、zlib等软件包。
1. 安装LAMP平台、启动服务并设置开机启动
[root@www ~]# yum install httpd* -y
[root@www ~]# yum install mysql* -y
[root@www ~]# yum install php* -y
[root@www ~]# service httpd start
[root@www ~]# service mysqld start
[root@www ~]# chkconfig --level 35 httpd on
[root@www ~]# chkconfig --level 35 mysqld on
2. 安装rrdtool软件包
rrdtool需要的软件包
libart_lgpl-2.3.17-4.i386
libpng-1.2.10-7.1.el5_3.2.i386
freetype-2.2.1-21.el5_3.i386 需预先安装
[root@www ~]# tar zxf rrdtool-1.2.27.tar.gz
[root@www ~]# cd rrdtool-1.2.27
[root@www rrdtool-1.2.27]# ./configure --prefix=/usr/local
[root@www rrdtool-1.2.27]# make
[root@www rrdtool-1.2.27]# make install
3. 安装配置Cacti服务器套件
安装Cacti文件包,解压至WEB服务器的网页目录,并添加用于读写监测数据的用户
[root@www ~]# cd /var/www/html/
[root@www html]# tar zxf cacti-0.8.7b-cn-utf8.tar.gz
[root@www html]# mv cacti-0.8.7b-cn-utf8 cacti
[root@www html]# useradd cactiuser
[root@www html]# chown -R cactiuser:cactiuser cacti/rra/ cacti/log/
设置监测数据库。
建立保存监测数据的数据库、表,设置好授权访问数据库的用户和密码
[root@www html]# service mysqld start
[root@www html]# mysql -u root -p
mysql> create database cactidb default character set utf8;
mysql> grant all on cactidb.* to cactiuser@localhost identified by '123';
mysql> exit
[root@www html]# mysql -u cactiuser -p cactidb < cacti/cacti.sql //导入数据表
4. 安装PA、Thold、Monitor插件扩展
[root@www ~]# cd /var/www/html/cacti
[root@www cacti]# tar zxf cacti-plugin-arch.tar.gz
[root@www cacti]# mysql -u cactiuser -p cactidb < cacti-plugin-arch/pa.sql
[root@www cacti]# gunzip -c cacti-plugin-0.8.7b-PA-v2.1-cn-utf8.diff.gz > PA-utf.diff
[root@www cacti]# patch -p1 -N < PA-utf.diff
[root@www cacti]# cd plugins
[root@www plugins]# tar zxf settings-0.5.tar.gz
[root@www plugins]# tar zxf monitor-0.8.2.tar.gz
[root@www plugins]# tar zxf thold-0.3.9.tar.gz
[root@www plugins]# mysql -u cactiuser -p cactidb < thold/thold.sql
[root@www plugins]# mysql -u cactiuser -p cactidb < monitor/monitor.sql
5.调整Cacti配置文件
[root@www cacti]# vi include/config.php
<?php
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "123";
$database_port = "3306";
$config['url_path'] = "/";
$plugins = array ();
$plugins[] = "settings";
$plugins[] = "thold";
$plugins[] = "monitor";
/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";
?>
6. 调整httpd设置
[root@www ~]# vi /etc/httpd/conf/httpd.conf
修改http.conf文件,以便支持自动查找索引页index.php,并将utf-8作为默认的中文页面字符集。
Listen 192.168.1.111:80
DocumentRoot "/var/www/html/cacti"
Options None
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
AddDefaultCharset UTF-8
7. 重启httpd服务,并查看其端口
[root@www ~]# service httpd restart
[root@www ~]# service mysqld restart
[root@www ~]# netstat -anpt | grep :80
8. 添加任务计划
[cactiuser@www ~]$ php /var/www/html/cacti/poller.php
[cactiuser@www ~]$ crontab –e
内容如下;
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php &>/dev/null
[cactiuser@www ~]$ exit
[root@www ~]# service crond start
[root@www ~]# chkconfig --level 2345 crond on

9. 通过web页面初始化安装cacti
使用web浏览器访问Cacti服务器,第一次访问Cacti界面时,会自动跳转到Cacti的初始化安装向导界面。如图,点击下一步即可






为了在监测图像中正常现实中文,还需要设置RRDtool所使用的中文字体路径,此版本的路径应为“/usr/share/fonts/zh_TW/TrueType/bsmi00lp.ttf”,点击右下方的保存即可。



阅读(967) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-08-28 08:59:57

Download More than 1000 free IT eBooks: http://free-ebooks.appspot.com