Chinaunix首页 | 论坛 | 博客
  • 博客访问: 541245
  • 博文数量: 81
  • 博客积分: 5015
  • 博客等级: 大校
  • 技术积分: 866
  • 用 户 组: 普通用户
  • 注册时间: 2005-03-25 09:08
个人简介

www.cloud86.cn

文章分类

全部博文(81)

文章存档

2017年(2)

2014年(1)

2011年(1)

2007年(5)

2006年(31)

2005年(41)

我的朋友

分类: LINUX

2006-06-23 11:47:16

在RedHat AS 4下安装支持中文的Cacti

LEO
2006-4-28

安装RedHat AS 4原始系统,不要选择Web服务器的所有包,选择Mysql开头的所有包,选择开发工具上面的所有包.

安装Apache
tar -zvxf httpd-2.2.tar.gz
cd httpd-2.2
./configure --prefix=/usr/local/apache --enable-so
make
make install

安装Net-snmp
在disk 2上执行
# rpm -ivh lm_sensors-2.8.7-2.i386.rpm
在disk 2,disk 4上执行
# rpm -ivh net-snmp*
# rpm -qa | grep net-snmp
net-snmp-libs-5.1.2-11
net-snmp-perl-5.1.2-11
net-snmp-5.1.2-11
net-snmp-devel-5.1.2-11
net-snmp-utils-5.1.2-11
# vi /etc/snmp/snmpd.conf
更改 1、com2sec notConfigUser default public
改为:com2sec notConfigUser 127.0.0.1 public
2、access notConfigGroup "" any noauth exact systemview none none
改为:access notConfigGroup "" any noauth exact all none none
3、#view all included .1 80
将前面的 # 注释 去掉。
保存退出 :wq
# service snmpd restart
# service mysqld start
/usr/local/apache/bin/apachectl start
chkconfig --level 345 snmpd on
chkconfig --level 345 mysqld on

* 设置环境变量
[root@leo ~]# mkdir /tmp/rrdbuild
[root@leo ~]# mkdir /usr/local/rrdtool-1.2.12
BUILD_DIR=/tmp/rrdbuild
INSTALL_DIR=/usr/local/rrdtool-1.2.12
* zlib
cd $BUILD_DIR
wget ... s/zlib-1.2.2.tar.gz
tar zxf zlib-1.2.2.tar.gz
cd zlib-1.2.2
env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lb
make
make install
* libpng
cd $BUILD_DIR
wget ... 1.2.8-config.tar.gz
tar zxvf libpng-1.2.8-config.tar.gz
cd libpng-1.2.8-config
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
* freetype
cd $BUILD_DIR
wget ... eetype-2.1.9.tar.gz
tar zxvf freetype-2.1.9.tar.gz
cd freetype-2.1.9
env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" \
./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
* libart_lgpl
cd $BUILD_DIR
wget ... _lgpl-2.3.17.tar.gz
tar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgpl-2.3.17
env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lb
make
make install
* 再次设置环境变量
IR=-I$BUILD_DIR/lb/include
CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"
LDFLAGS="-L$BUILD_DIR/lb/lib"
CFLAGS=-O3
export CPPFLAGS LDFLAGS CFLAGS
* rrdtool
mkdir $BUILD_DIR/rrdtool-1.2.12
cd $BUILD_DIR/rrdtool-1.2.12
wget
tar zxvf rrdtool-1.2.12.tar.gz
cd rrdtool-1.2.12/src/

rrdtool 1.2.12 中文化 Patch , 若不懂 patch 请先研究用法
(建议手动修改源代码)
新版的 rrd (1.2.x) 调用 FT (freetype2) 做 TTF 输出
所以程序用 1.0.x 版完全不能适用哦,切记

# diff -u rrd_gfx.c.bak rrd_gfx.c
--- rrd_gfx.c.bak 2005-12-19 04:30:45.000000000 +0800
+++ rrd_gfx.c 2006-04-23 11:05:47.000000000 +0800
@@ -384,6 +384,7 @@
int n;
int error;
int gottab = 0;
+ wchar_t* w_text;

#ifdef HAVE_MBSTOWCS
wchar_t *cstr;
@@ -414,6 +415,8 @@
string->transform.xy = (FT_Fixed)(-sin(M_PI*(rotation)/180.0)*0x10000);
string->transform.yx = (FT_Fixed)( sin(M_PI*(rotation)/180.0)*0x10000);
string->transform.yy = (FT_Fixed)( cos(M_PI*(rotation)/180.0)*0x10000);
+ w_text = (wchar_t) calloc (string->count,sizeof(wchar_t));
+ mbstowcs(w_text,text,string->count);

use_kerning = FT_HAS_KERNING(face);
previous = 0;
@@ -443,7 +446,7 @@
glyph->pos.x = 0;
glyph->pos.y = 0;
glyph->image = NULL;
- glyph->index = FT_Get_Char_Index( face, letter );
+ glyph->index = FT_Get_Char_Index( face, w_text[n]);

/* compute glyph origin */
if ( use_kerning && previous && glyph->index ) {
@@ -516,6 +519,7 @@
string->width = string->bbox.xMax - string->bbox.xMin;
} */
string->height = string->bbox.yMax - string->bbox.yMin;
+ free(w_text);
return string;
}

diff -u rrd_graph.c.bak rrd_graph.c
--- rrd_graph.c.bak 2005-12-19 04:30:45.000000000 +0800
+++ rrd_graph.c 2006-04-23 11:05:53.000000000 +0800
@@ -2871,7 +2871,8 @@
tzset();
#endif
#ifdef HAVE_SETLOCALE
- setlocale(LC_TIME,"");
+ //setlocale(LC_TIME,"");
+ setlocale(LC_ALL,"zh_CN.GB2312");
#endif
im->yorigin=0;
im->xorigin=0;

打完补丁后,继续
cd /tmp/rrdbuild/rrdtool-1.2.12/rrdtool-1.2.12
./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl
make clean
make
make install
* GD
cd $BUILD_DIR
wget ... er/gd-2.0.33.tar.gz
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd --with-freetype=/usr/local/freetype --
with-libpng=/usr/local/libpng
make
make install

PHP:
cd $BUILD_DIR
wget
tar zxvf php-5.1.2.tar.gz
cd php-5.1.2
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/lib/mysql --with-gd=/usr/local/gd --with-zlib --with-png=/usr/local/libpng --with-jpeg --with-freetype=/usr/local/freetype --enable-sockets
make
make install
cp ./php.ini-dist /usr/local/lib/php.ini

修改httpd.conf
#vi /usr/local/apache/conf/httpd.conf
加载php模块,去掉注释“#”,如没有此行,请加上。
LoadModule php5_module modules/libphp5.so
加上此两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

DirectoryIndex index.html
在后面加上 index.php
如下:
DirectoryIndex index.html index.php
重启Apache生效

Cacti:
cp cacti-0.8.6g.tar.gz /usr/local/apache/htdocs
cd /usr/local/apache/htdocs
tar zxvf cacti-0.8.6g.tar.gz
mv cacti-0.8.6g cacti
cd cacti
mysqladmin -uroot create cacti
mysql -uroot cacti < cacti.sql
创建帐号:
mysql -uroot
grant all privileges on cacti.* to cactiuser@localhost identified by 'cacti';
flush privileges;
exit
useradd cactiuser
chown –R cactiuser rra/ log/
vi ./include/config.php
$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cacti”;
vi /etc/crontab
*/5 * * * * cactiuser /usr/local/bin/php /usr/local/apache/htdocs/cacti/poller.php > /dev/null 2>&1

我们发现,如果将一个device以中文命名,会在devices页面出现乱码,而且图像也会出现乱码。为了解决这些问题,实现使用中文的目的,我们需要修改cacti和rrdtool的代码,以让其支持中文。
注意:我这里所说的“支持中文”只是让cacti能显示中文,而不是将cacti全部汉化。如果有朋友有兴趣想要为cacti的汉化出一份力的话,可以联系其作者。

软件版本:
cacti-0.8.6g
rrdtool-1.2.12
支持中文环境的linux

最后在cacti的“setting”-》“Paths”-》“RRDTool Default Font Path”中填上中文的fonts,比如:“/usr/share/fonts/zh_CN/TrueType/gbsn00lp.ttf”。

在支持中文环境的linux上能成功实现中文显示。

输入下面地址测试:

默认的用户名和密码都是admin.
阅读(2287) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~