歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> Linux文化

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


安裝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 http://people.ee.ethz.ch/oetiker ... 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 http://people.ee.ethz.ch/oetiker ... 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 http://people.ee.ethz.ch/oetiker ... 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 http://people.ee.ethz.ch/oetiker ... _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 http://211.155.16.55/linux_soft/rrdtool-1.2.12.tar.gz 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 http://211.155.16.55/linux_soft/ ... 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 http://211.155.16.55/linux_soft/php-5.1.2.tar.gz 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上能成功實現中文顯示。

輸入下面地址測試: http://127.0.0.1/cacti/ 默認的用戶名和密碼都是admin.

Copyright © Linux教程網 All Rights Reserved