'Linux tools/MRTG'에 해당되는 글 3건






 STEP 1.

Weathermap4RRD는 Perl 버전과 PHP 버전이 있는데 PHP 버전으로 설치하고, 사용 할 것이다.
PHP 버전을 설치 하기에 앞서 PHP를 먼저 설치해야 한다.

[root@mrtg mrtg]# cd /usr/local/rrdbuild/
[root@mrtg rrdbuild]# wget http://kr2.php.net/get/php-5.2.13.tar.gz/from/kr.php.net/mirror
--2010-03-26 10:56:49--  http://kr2.php.net/get/php-5.2.13.tar.gz/from/kr.php.net/mirror
Resolving kr2.php.net... 211.234.110.150
Connecting to kr2.php.net|211.234.110.150|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location:
http://kr.php.net/distributions/php-5.2.13.tar.gz [following]
--2010-03-26 10:56:49-- 
http://kr.php.net/distributions/php-5.2.13.tar.gz
Resolving kr.php.net... 115.165.178.40
Connecting to kr.php.net|115.165.178.40|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11719620 (11M) [application/x-gzip]
Saving to: `php-5.2.13.tar.gz'

100%[=======================================================================>] 11,719,620  3.55M/s   in 3.1s   

2010-03-26 10:56:52 (3.55 MB/s) - `php-5.2.13.tar.gz' saved [11719620/11719620]

[root@mrtg rrdbuild]#


PHP를 다운 받았으므로, 이제 압축을 해제하고 설치를 시작 하겠다.

[root@mrtg rrdbuild]# tar xvfz php-5.2.13.tar.gz
................ 생략(참고로 PHP는 굉장히 오랫 동안 압축을 푼다) ................
php-5.2.13/README.SELF-CONTAINED-EXTENSIONS
php-5.2.13/stub.c
php-5.2.13/buildconf
php-5.2.13/stamp-h.in
php-5.2.13/README.SVN-RULES
php-5.2.13/README.input_filter
php-5.2.13/generated_lists
php-5.2.13/README.Zeus
php-5.2.13/INSTALL
php-5.2.13/TODO-PHP5
php-5.2.13/EXTENSIONS
php-5.2.13/server-tests-config.php
php-5.2.13/snapshot
php-5.2.13/php.gif
php-5.2.13/README.PARAMETER_PARSING_API
php-5.2.13/acconfig.h
php-5.2.13/README.PHP4-TO-PHP5-THIN-CHANGES
php-5.2.13/CREDITS
php-5.2.13/README.UPDATE_5_2
php-5.2.13/README.UNIX-BUILD-SYSTEM
php-5.2.13/buildconf.bat

[root@mrtg rrdbuild]# cd php-5.2.13
[root@mrtg php-5.2.13]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --disable-debug --enable-safe-mode --enable-sockets --enable-sysvsem=yes --enable-sysvshm=yes --enable-ftp --enable-magic-quotes --enable-gd-native-ttf --enable-inline-optimization --enable-bcmath --with-zlib --with-jpeg-dir=/usr --with-png-dir=/usr/lib --with-freetype-dir=/usr --with-libxml-dir=/usr --enable-exif --with-gd --with-ttf --with-gettext --enable-sigchild --enable-mbstring
.............. 생략(이것 역시 길다)...............
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool

Generating files
updating cache ./config.cache
creating ./config.status
creating php5.spec
creating main/build-defs.h
creating scripts/phpize
creating scripts/man1/phpize.1
creating scripts/php-config
creating scripts/man1/php-config.1
creating sapi/cli/php.1
creating main/php_config.h
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[root@mrtg php-5.2.13]#

--prefix=/usr/local/php는 php가 설치될 디렉토리 경로이다.
--with-apxs2=/usr/local/apache/bin/apxs는 Apache의 apxs를 이용해 아파치에 모듈을 적재한다.
--with-config-file-path=/usr/local/apache/conf는 php의 환경설정 파일인 php.ini가 생성 될 위치이다.

그 외 각종 라이브러리를 포함하는 옵션이다.



[root@mrtg php-5.2.13]# make
/bin/sh /usr/local/rrdbuild/php-5.2.13/libtool --silent --preserve-dup-deps --mode=compile gcc -Iext/date/lib -Iext/date/ -I/usr/local/rrdbuild/php-5.2.13/ext/date/ -DPHP_ATOM_INC -I/usr/local/rrdbuild/php-5.2.13/include -I/usr/local/rrdbuild/php-5.2.13/main -I/usr/local/rrdbuild/php-5.2.13 -I/usr/local/rrdbuild/php-5.2.13/ext/date/lib -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/local/rrdbuild/php-5.2.13/ext/mbstring/oniguruma -I/usr/local/rrdbuild/php-5.2.13/ext/mbstring/libmbfl -I/usr/local/rrdbuild/php-5.2.13/ext/mbstring/libmbfl/mbfl -I/usr/local/rrdbuild/php-5.2.13/TSRM -I/usr/local/rrdbuild/php-5.2.13/Zend    -I/usr/include -g -O2  -prefer-non-pic -c /usr/local/rrdbuild/php-5.2.13/ext/date/php_date.c -o ext/date/php_date.lo
/bin/sh /usr/local/rrdbuild/php-5.2.13/libtool --silent --preserve-dup-deps --mode=compile gcc -Iext/date/lib -Iext/date/ -I/usr/local/rrdbuild/php-5.2.13/ext/date/ -DPHP_ATOM_INC -I/usr/local/rrdbuild/php-5.2.13/include -I/usr/local/rrdbuild/php-5.2.13/main -I/usr/local/rrdbuild/php-5.2.13 -I/usr/local/rrdbuild/php-5.2.13/ext/date/lib -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/local/rrdbuild/php-5.2.13/ext/mbstring/oniguruma -I/usr/local/rrdbuild/php-5.2.13/ext/mbstring/libmbfl -I/usr/local/rrdbuild/php-5.2.13/ext/mbstring/libmbfl/mbfl -I/usr/local/rrdbuild/php-5.2.13/TSRM -I/usr/local/rrdbuild/php-5.2.13/Zend    -I/usr/include -g -O2  -prefer-non-pic -c /usr/local/rrdbuild/php-5.2.13/ext/date/lib/astro.c -o ext/date/lib/astro.lo
............... 생략 ..............
ge_scanner.lo Zend/zend_ini_parser.lo Zend/zend_ini_scanner.lo Zend/zend_alloc.lo Zend/zend_compile.lo Zend/zend_constants.lo Zend/zend_dynamic_array.lo Zend/zend_execute_API.lo Zend/zend_highlight.lo Zend/zend_llist.lo Zend/zend_opcode.lo Zend/zend_operators.lo Zend/zend_ptr_stack.lo Zend/zend_stack.lo Zend/zend_variables.lo Zend/zend.lo Zend/zend_API.lo Zend/zend_extensions.lo Zend/zend_hash.lo Zend/zend_list.lo Zend/zend_indent.lo Zend/zend_builtin_functions.lo Zend/zend_sprintf.lo Zend/zend_ini.lo Zend/zend_qsort.lo Zend/zend_multibyte.lo Zend/zend_ts_hash.lo Zend/zend_stream.lo Zend/zend_iterators.lo Zend/zend_interfaces.lo Zend/zend_exceptions.lo Zend/zend_strtod.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo sapi/cli/php_cli.lo sapi/cli/php_cli_readline.lo sapi/cli/getopt.lo main/internal_functions_cli.lo -lcrypt -lcrypt -lrt -lfreetype -lpng -lz -ljpeg -lz -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt  -o sapi/cli/php

Build complete.
Don't forget to run 'make test'.


[root@mrtg php-5.2.13]# make install
Installing PHP SAPI module:       apache2handler
/usr/local/apache/build/instdso.sh SH_LIBTOOL='/usr/local/apache/build/libtool' libphp5.la /usr/local/apache/modules
/usr/local/apache/build/libtool --mode=install cp libphp5.la /usr/local/apache/modules/
cp .libs/libphp5.so /usr/local/apache/modules/libphp5.so
cp .libs/libphp5.lai /usr/local/apache/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /usr/local/rrdbuild/php-5.2.13/libs'
chmod 755 /usr/local/apache/modules/libphp5.so
[activating module `php5' in /usr/local/apache/conf/httpd.conf]
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.3
[PEAR] Console_Getopt - installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.2
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.0
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

[root@mrtg php-5.2.13]#



PHP의 환경 설정을 한다. /usr/local/apache/conf에 php.ini라는 이름으로 복사 한다.

[root@mrtg php-5.2.13]# cp php.ini-dist /usr/local/apache/conf/php.ini
[root@mrtg php-5.2.13]#


웹서버(아파치)와 연동하기 위해서는 httpd.conf를 수정해야 하는데 앞에서 웹서버 설치 할 때 이미 php 관련된 사항을 모두 입력 하였다. 그래도 확인 차원에서 입력해야 하는 부분을 다시 한번 보여주겠다.

[root@mrtg php-5.2.13]# vi /usr/local/apache/conf/httpd.conf
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php index.cgi
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being




    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    AddType application/x-httpd-cgi .cgi .pl
    #
    # AddHandler allows you to map certain file extensions to "handlers":




웹서버를 멈췄다가 다시 시작하여, 테스트를 해 보도록 한다.

[root@mrtg php-5.2.13]# /usr/local/apache/bin/apachectl stop
[root@mrtg php-5.2.13]# /usr/local/apache/bin/apachectl start
[root@mrtg php-5.2.13]#



테스트 페이지를 만들어서 php의 정보를 보여주는 함수를 사용해 본다.

[root@mrtg php-5.2.13]# vi /usr/local/apache/htdocs/phpinfo.php
<? phpinfo(); ?>
[root@mrtg php-5.2.13]#


위와 같이 웹브라우저를 띄우고 웹서버 주소에서 phpinfo.php를 입력하면 PHP 정보가 나오게 된다.





STEP 2.

이제 본격적으로 Weathermap4RRD를 설치 할 것이다. 우선 Weathermap4RRD를 다운 받고 압축을 해제한다.

[root@mrtg php-5.2.13]# cd /usr/local/rrdbuild/
[root@mrtg rrdbuild]# lftpget "http://weathermap4rrd.tropicalex.net/get_file.php?id=21&path=/code&filename=weathermap4rrd-php-1.2bfinal.tgz"

위에서 파일을 받을 주소가 특수문자(?, &)등을 포함하고 있어서 wget이나 lftpget만 입력하면 제대로 파일을 다운로드하지 못하여 주소에 " " 로 묶어주었다. wget으로 받은 경우에는 ? 뒤부터 파일 이름으로 해석을 한 반면, lftpget을 이용하니 제대로 weathermap4rrd-php-1.2bfinal.tgz으로 받아졌다.


[root@mrtg rrdbuild]# tar xvfz weathermap4rrd-php-1.2bfinal.tgz
weathermap4rrd-php-1.2bfinal/
weathermap4rrd-php-1.2bfinal/graph.php
weathermap4rrd-php-1.2bfinal/net.php
weathermap4rrd-php-1.2bfinal/graphic.php
weathermap4rrd-php-1.2bfinal/INSTALL
weathermap4rrd-php-1.2bfinal/overlib_mini.js
weathermap4rrd-php-1.2bfinal/weathermap.conf
weathermap4rrd-php-1.2bfinal/rrd.php
weathermap4rrd-php-1.2bfinal/w4rrd.php
weathermap4rrd-php-1.2bfinal/config.php
weathermap4rrd-php-1.2bfinal/map.htm
weathermap4rrd-php-1.2bfinal/histo.php
weathermap4rrd-php-1.2bfinal/overlib.js
weathermap4rrd-php-1.2bfinal/CHANGELOG
weathermap4rrd-php-1.2bfinal/linkgraph.php
weathermap4rrd-php-1.2bfinal/overlib/
weathermap4rrd-php-1.2bfinal/index.php
weathermap4rrd-php-1.2bfinal/README
weathermap4rrd-php-1.2bfinal/icons/
weathermap4rrd-php-1.2bfinal/icons/wireless_router.png
weathermap4rrd-php-1.2bfinal/icons/router_cisco.png
weathermap4rrd-php-1.2bfinal/icons/terminal.png
weathermap4rrd-php-1.2bfinal/icons/router2.png
weathermap4rrd-php-1.2bfinal/icons/pix.png
weathermap4rrd-php-1.2bfinal/icons/server.png
weathermap4rrd-php-1.2bfinal/config_tool.php
weathermap4rrd-php-1.2bfinal/LICENSE
weathermap4rrd-php-1.2bfinal/currentvalues.php

[root@mrtg rrdbuild]#


압축을 해제하였으니, 이제 config.php와 weathermap.conf를 편집한다.
config.php는 RRDTool 실행을 위한 경로 설정과 weahtermap.conf의 경로를 설정한다.
weahtermap.conf에서는 weahtermap에서의 노드와 회선등의 설정 정보를 정의한다.


우선 config.php 파일을 수정한다.

[root@mrtg rrdbuild]# cd weathermap4rrd-php-1.2bfinal
[root@mrtg weathermap4rrd-php-1.2bfinal]# vi config.php

<?php

//$rrdtool = "/usr/bin/rrdtool";
//$rrdtool = "/usr/src/rrdtool-1.3.6/src/rrdtool";
$rrdtool = "/usr/local/rrdtool-1.2.12/bin/rrdtool";


# You have to set up this variable to your weathermap4rrd path
# it will be used to read config file
$weathermap4php= dirname($_SERVER['PATH_TRANSLATED']);
#$configfile=$weathermap4php."/weathermap.conf";
$configfile=$_GET['config'];
if (empty($configfile)) {
        if (empty($weathermap4php)) {
            $configfile = "weathermap.conf";
        } else {
            $configfile = $weathermap4php."/weathermap.conf";
        }
} else {
        if (empty($weathermap4php)) {
            $configfile = $configfile;
        } else {
            $configfile = $weathermap4php."/".$configfile;
        }
}



weahtermap.conf를 수정한다. 웹서버에서 구동시키기 위하여, weathermap4rrd-php-1.2bfinal 디렉토리를 웹서버가 위치한 디렉토리로 복사를 할 것이다.

[root@mrtg weathermap4rrd-php-1.2bfinal]# cd /usr/local/rrdbuild/
[root@mrtg rrdbuild]# cp -r weathermap4rrd-php-1.2bfinal /usr/local/apache/htdocs/weathermap
[root@mrtg rrdbuild]# cd /usr/local/apache/htdocs/weathermap/
[root@mrtg weathermap]# vi weathermap.conf
# This file is an example of what directives may be used in your configuration file. For more details, please visit :
#
#
http://weathermap4rrd.tropicalex.net
# December 2005  /  Alexandre Fontelle

# BACKGROUND directive defines a background PNG file.
# (optional)
#BACKGROUND france_.png

# Size of image generated if no background has been defined. If one background is defined, size of background will be used.
HEIGHT 600
WIDTH 740

# FONT from 1 to 5 (define size of font that will be used in graph to display node's names, title...)
FONT 4

# Position of legend
LEGENDPOS       300 460

# LEGENDSTYLE should be "orignal" or "line"
LEGENDSTYLE     line

# label of TITLE
TITLE "Example Tropicalex Network map"
# Position of title in graph
TITLEPOS 4 470
# Color of background title
TITLEBACKGROUND 255 255 128
# Color of font to display title
TITLEFOREGROUND 0 0 0

# Allow to define if CHECK directive in NODE section has to be used or not
# *******
# WARNING : use of this feature could really slow generation of map because of ping function call (especially when a node is down)
# *******
# IPCHECK default value is 0
IPCHECK 0

# Time between two refresh of display in seconds
REFRESH 40

# OUTPUTFILE define path and name of PNG picture that will be generated
OUTPUTFILE /var/www/weathermap4rrdtest.tropicalex.net/htdocs/weathermap4rrd-php-1.2final/weathermap.png
# HTMLFILE define path and name of html file that will be generated to store html map of network weathermap
HTMLFILE /var/www/weathermap4rrdtest.tropicalex.net/htdocs/weathermap4rrd-php-1.2final/weathermap.html

# Legend colors and boundaries values
# For example first line means that between 1 and 10% of bandwidth use, color used to draw the arrow will be RGB(140,0,255)
#     low  high   red green blue
SCALE   1   10    140     0  255
SCALE  10   25     32    32  255
SCALE  25   40      0   192  255
SCALE  40   55      0   240    0
SCALE  55   70    240   240    0
SCALE  70   85    255   192    0
SCALE  85  90     255   100    0
SCALE  90  100    255     0    0

# You may use AUTOSCALE directive to create a dynamic colors scale
# Example of AUTOSCALE syntax :
# AUTOSCALE 15 24 232 2 0 0 0
# AUTOSCALE 11

################
# NODES SECTION #
################

# Name of node (this name won't be displayed on map)
NODE Freebackbone
                # Position of node in the map
        POSITION 135 125
                # Name that will be displayed on the map in label
        LABEL Freebackbone
                # You have ability to choose between several kind of label : "round" or "normal" for square
                LABELTYPE round

NODE Bastille2
        POSITION 200 387
                # You need to define IP of node if you plan to use CHECK directive (see below)
                IP 192.168.0.7
                # Weathermap4rrd will test if node is down or up with a TCP request on port 80 of node
                # *******
                # WARNING : use of this feature could really slow generation of map (especially when a node is down)
                # *******
                CHECK tcp 80
        LABEL Bastille2
                LABELTYPE       round
                # LABELTPT defined transparency of node on network weathermap.
                # Be careful 0 will disable LABELTPT value reading and it will be like LABELTPT 100
                LABELTPT        80
                # You may associate an icon to your node. To do so, use ICON directive
                # Icon has to be a PNG file format
                ICON icons/router_cisco.png
                # You may want to resize icon...then use ICONRESIZE. Value is in % of original image. In this example icon displayed on map will be 75% of original size
                ICONRESIZE 75

NODE k7
        POSITION 478 387
                IP 192.168.0.8
                # Weathermap4rrd will test if node is down or up with a "ping" request (use ICMP protocol).
                # *******
                # WARNING : use of this feature could really slow generation of map (especially when a node is down)
                # *******
                CHECK ping
        LABEL K7
                # if no LABELTYPE is defined, default is "normal" (square)
#               LABELTYPE round
                ICON icons/terminal.png
                ICONTPT 50

NODE switch    
                POSITION 405 125
                LABEL switch
                LABELTYPE round

NODE workstation1
                POSITION 500 250
                LABEL workstation1
                LABELTYPE round

NODE workstation2
                POSITION 500 300
                LABEL workstation2
                LABELTYPE round


#################
# LINKS section #
#################

# Name of link (won't be displayed on map, just useful for internal use of weathermap4rrd)
LINK internet-switch
                # Put name of nodes A and B that are linked
        NODES   Freebackbone switch
                # Define file where interfaces trafic values have to be read (could be a MRTG file or RRD file). See
http://weathermap4rrd.tropicalex.net for details
                # You may have a different file for inbound and outbound values. If so, use TARGETIN and TARGETOUT directives.
        TARGET  /home/monitor/monitoring/rrd/bastille2.eth1.rrd                 # LINKOVERLIBGRAPH allow you to display a popup window when mouse cursor is over a link. Content of this window will be result of call to script defined as value of LINKOVERLIBGRAPH directive. If LINKOVERLIBGRAPH is used without parameter (as in this example), script graph.php will be used.
                LINKOVERLIBGRAPH
                # LINKINFOURL defined URL link that will be used if you click on link. Default is globalgraph (that in fact called linkgraph.php)
                # You may put what you like
                LINKINFOURL globalgraph
                # Define position of RRA in RRD file for inbound bandwidth values for node A (here Freebackbone)
                INPOS   1
                # Define position of RRA in RRD file for outbound bandwidth values for node A (here Freebackbone)
                OUTPOS  2
                # UNIT defines unit of values stored in TARGET file
                UNIT    bytes
                # Define bandwidth of link in Kilobits
                BANDWIDTH 316
                # DISPLAYVALUE allow you to display value of bandwith just below the % bandwidth
                DISPLAYVALUE 1
                # Type of ARROW to display. You may choose between : "normal", "round" or "halfarrow"
                ARROW   halfarrow
                # You may create group of link in order to filter display
                GROUP   dsl
                #INTERNODEDISPLAY 100
                # Define if middle internode will be displayed when number of internodes is odd
                INTERNODEDISPLAYMID no
                INTERNODEDISPLAYNUM no

LINK internet-Bastille2
        NODES   Freebackbone Bastille2
        TARGET  /home/monitor/monitoring/rrd/bastille2.eth1.rrd
#               LINKOVERLIBGRAPH
http://www.google.fr/intl/fr_fr/images/logo.gif
                LINKOVERLIBGRAPH
                LINKINFOURL globalgraph
                INPOS   1
                OUTPOS  2
                UNIT    bytes
                BANDWIDTH 316
                DISPLAYVALUE 1
                ARROW   normal
                # Define points that have to be used to draw link between nodes A & B
                INTERNODE       135 250
                # Define  transparency of round that will be display on internode position
                INTERNODEDISPLAY 75
                # When there is a odd number of internodes defined. You may choose if you want to display a round as for an internode in middle of link.
                INTERNODEDISPLAYMID no
                # You may want to display a number in round (for debug)
                INTERNODEDISPLAYNUM no

LINK k7-Bastille2
                NODES   Bastille2 k7
                TARGETOUT /home/monitor/monitoring/rrd/bastille2.eri0.rrd
                TARGETIN /home/monitor/monitoring/rrd/bastille2.eri0.rrd
                LINKOVERLIBGRAPH currentvalues.php
                LINKINFOURL globalgraph
                INPOS   1
                OUTPOS  2
                UNIT    bytes
                BANDWIDTH       316
                DISPLAYVALUE    1
                ARROW   normal


LINK switch-workstation1
                NODES switch workstation1
                TARGET /home/monitor/monitoring/rrd/bastille2.eri0.rrd
                INPOS   1
                OUTPOS  2
                UNIT    bytes  
                BANDWIDTH       31
                DISPLAYVALUE    0
                ARROW   circle
                INTERNODE 500 125

LINK switch-workstation2
                NODES switch workstation2
                TARGET /home/monitor/monitoring/rrd/bastille2.eri0.rrd
                INPOS   1
                OUTPOS  2
                UNIT    bytes  
                BANDWIDTH       13
                DISPLAYVALUE    0
                ARROW   circle
                INTERNODE 405 300
                INTERNODEDISPLAY 75



weathermap.conf는 위와 같이 되어있을 것이다.

OUTPUTFILE에서는 Weahtermap을 경험해 본 사람은 알겠지만, html로 생성 된 파일에서 스크린을 png 파일로 변환하여 저장을 할 수 있는 경로를 입력한다.

HTMLFILE에서는 웹브라우저에서 볼 수 있게 weathermap.html이 생성 될 경로를 입력한다. 사용자 편의에 맞춰 이름이나 경로 수정이 가능하다.

SCALE은 그래프에서 구간을 설정하여 트래픽을 나타내는 화살표를 색으로 구분 할 수 있게 해준다.
기본으로 들어있는 파일을 살펴보면 SCALE 1  10  140  0  255 라고 되어있다. 물론 그 위에 #으로 주석처리를 하여 low high red green blue라고 써 있는 것을 확인 할 수 있다.
트래픽이 1~10%까지 트래픽의 경우에는 화살표의 색상을 색상표 RGB에 맞춰 Red 140 , Green 0 , Blue 255로 색깔을 표현 할 것이다. 사용자가 구축하는 서버의 특성에 맞춰서 %의 단위나, 색상이나 변경이 가능하다.

NODE는 트래픽 화살표를 그리기 위한 축이라고 할 수 있으며, NODE의 이름으로 LINK를 표현 할 때 이용되므로 서버 관리자가 관리하기 편하고 기억하기 쉽게 정리하는 것이 좋다. POSITION을 통해서 X축과 Y축 값에 따라 위치를 정할 수 있다. 웹브라우저에서 위치를 정할 때는 조금씩 수정하고, 새로고침 하는것이 가장 좋은 방법이라고 생각한다.
LABEL은 NODE에 마우스를 가져가면 띄워주는 라벨이며, IP를 입력하면 ping 테스트를 하며, ping이 정상적인 경우에는 녹색으로 정상적으로 되지 않을 경우에는 붉은색으로 표시한다. LABELTYPE으로 라벨의 모양이나 위치 등도 변경이 가능하다.
ICON 등을 하위 경로 등에 두어 NODE에 이미지를 넣을 수 도 있고, ICONSIZE를 통해서 이미지의 사이즈도 변경이 가능하다. ICONESIZE 75는 이미지의 75%로 표시 한다는 의미이다.

LINK는 NODE와 NODE를 이어주는 화살표라고 할 수 있으며, TARGET을 통해 서버에 저장된 rrd 파일을 읽어와서 맵에 맞게 표현해준다.
LINKINFOURL을 통해 특정 회선에 대한 MRTG를 웨더맵과 연동한다.
LINKOVERLIBGRAPH 옵션을 통해서 마우스 포인터가 화살표에 올라가면, MRTG 그래프를 표시해주기도 한다.
트래픽의 BANDWIDTH나 ARROW의 옵션을 통하여 화살표를 양방향, 단방향등 여러가지 옵션을 줄 수 있다.



설정을 변경 하였는데도 그래프가 아래 그림과 같이 나올 것이다.




위에 설정에서 알 수 있듯이 weahtermap을 표현하기 위해서는 html과 png 파일등을 쓰거나 실행 할 수 있어야 한다.
[root@mrtg weathermap]# cd /usr/local/apache/htdocs/
[root@mrtg htdocs]# chmod 777 weathermap/
[root@mrtg htdocs]#


권한 변경 후 아래와 같이 그래프가 제대로 나오기 시작한다.
설정 부분은 본인이 직접 운영을 하면서 시행착오를 거치다보면 더 좋은 Weahtermap을 표현 할 수 있다고 생각한다.




'Linux tools > MRTG' 카테고리의 다른 글

MRTG 설정 및 사용하기  (0) 2010.03.25
MRTG 설치 방법  (0) 2010.03.23
블로그 이미지

쭈꾸댕이

아직 어설픈 실력으로 나름 제가 하는 것에 대한 것들을 옮기는 공간입니다. 틀린 부분도 있을 수 있으니 이 점 양해하시고, 도움이 되셨으면 좋겠네요.

,





STEP 1.

MRTG를 설치하였으니 이제 MRTG를 사용하는 방법에 대해서 알아보도록 하겠다.
내 경우에는 MRTG를 관리 할 계정으로 mrtg 라는 계정을 만들었으며, 그 디렉토리 안에 cfg, data, log를 만들었다.

[root@mrtg cfg]# cfgmaker --global Workdir:/home/mrtg/data --global 'Options[_]:growright,bits' --output=/home/mrtg/cfg/test.cfg public@123.123.123.123:::::2
--base: Get Device Info on public@123.123.123.123:::::2
--base: Vendor Id: cisco
--base: Populating confcache
--coca: populate confcache
public@123.123.123.123:::::2
--coca: store in confcache public@123.123.123.123__2 Name Te3/1 --> 1
--coca: store in confcache
public@123.123.123.123__2 Name Te3/2 --> 2
--coca: store in confcache
public@123.123.123.123__2 Name Gi5/1 --> 3
--coca: store in confcache
public@123.123.123.123__2 Name Gi5/2 --> 4
--coca: store in confcache
public@123.123.123.123__2 Name Gi7/1 --> 5
--coca: store in confcache
public@123.123.123.123__2 Name Gi7/2 --> 6
--coca: store in confcache
public@123.123.123.123__2 Name Vl1 --> 7
--coca: store in confcache
public@123.123.123.123__2 Descr TenGigabitEthernet3/1 --> 1
--coca: store in confcache
public@123.123.123.123__2 Descr TenGigabitEthernet3/2 --> 2
--coca: store in confcache
public@123.123.123.123__2 Descr GigabitEthernet5/1 --> 3
--coca: store in confcache
public@123.123.123.123__2 Descr GigabitEthernet5/2 --> 4
--coca: store in confcache
public@123.123.123.123__2 Descr GigabitEthernet7/1 --> 5
--coca: store in confcache
public@123.123.123.123__2 Descr GigabitEthernet7/2 --> 6
--coca: store in confcache
public@123.123.123.123__2 Descr Vlan1 --> 7
--coca: store in confcache
public@123.123.123.123__2 Type 6 --> 1
--coca: store in confcache
public@123.123.123.123__2 Type 6 --> 2 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Type 6 --> 3 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Type 6 --> 4 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Type 6 --> 5 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Type 6 --> 6 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Type 53 --> 7
--coca: store in confcache
public@123.123.123.123__2 Eth 00-16-9d-ab-13-78 --> 1
--coca: store in confcache
public@123.123.123.123__2 Eth 00-1c-b0-b6-67-40 --> 2
--coca: store in confcache
public@123.123.123.123__2 Eth 00-1c-b0-b6-67-40 --> 3 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Eth 00-1c-b0-b6-67-40 --> 4 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Eth 00-16-46-e3-18-18 --> 5
--coca: store in confcache
public@123.123.123.123__2 Eth 00-1c-b0-b6-67-40 --> 6 (duplicate)
--coca: store in confcache
public@123.123.123.123__2 Eth 00-00-15-00-00-00 --> 7
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifMtu
--base: Walking ifAlias
--base: Walking vmVlan
--base: Walking ifSpeed
--base: Walking ifHighSpeed
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.1 -> 10000 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.1 -> 2554890072645173
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.2 -> 10000 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.2 -> 0
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.3 -> 1000 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.3 -> 88837206
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.4 -> 100 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.4 -> 294876
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.5 -> 1000 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.5 -> 8261120
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.6 -> 1000 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.6 -> 0
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHighSpeed.7 -> 100 Mb/s
--base: snmpget
public@123.123.123.123:::::2:v4only for ifHCInOctets.7 -> 1120902719935
--base: check for HighspeedCounters failed ... Dropping back to V1
--base: Writing /home/mrtg/cfg/test.cfg

[root@mrtg cfg]#

보안상 내가 설치한 서버의 정보는 공개하지 않았다.
--global Workdir:/home/mrtg/data는 MRTG의 작업 디렉토리를 지정 하는 것이다. 이 때 MRTG는 MRTG의 로그 파일 및 웹 페이지 작업을 디렉토리에 생성한다.
--global 'Options[_]:growright,bits'는 MRTG 그래프에서 트래픽에 관한 표시를 Bit per Second로 하여 X축의 시간 증가가 오른쪽임을 의미한다.
output=/home/cfg/test.cfg는 cfgmaker를 통하여 생선한 cfg 파일 저장 경로와 파일의 이름을 의미한다.
public@123.123.123.123:::::2는 트래픽 정보를 수집하는 라우터에 관한 정보로 123.123.123.123은 라우터 IP의 정보이며, public은 community를 통해 SNMP Request로 접근함을 의미한다. :::::2는 SNMP v2로 접근하는 것을 의미한다.




STEP 2.

MRTG를 주기적으로 라우터의 트래픽 정보를 수집하는 것은 cron을 이용하여 주기적으로 MRTG를 실행시키는 방법과 MRTG의 데몬 모드로 실행시켜 주기적으로 데이터를 수집 할 수 있다.

cron을 통해 주기적으로 실행시키면 실행을 할 때 마다 MRTG cfg 파일을 읽어 초기화 하는 단점이 있기 때문에 MRTG 데몬 모드를 실행하는 것이 더 효율적이어서 MRTG 데몬 모드로 실행하는 방법을 설명하겠다.

[root@mrtg cfg]# vi test.cfg
# Created by
# /usr/local/mrtg-2/bin/cfgmaker --global Workdir:/home/mrtg/data --global 'Options[_]:growright,bits' --output=/home/mrtg/cfg/test.cfg
public@123.123.123.123:::::2


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no
Workdir:/home/mrtg/data
Options[_]:growright,bits

######################################################################
# System: Cisco-Router
# Description: Cisco Internetwork Operating System Software


test.cfg 파일을 열었을 경우 위와 같은 설정으로 생성이 되어있다.
여기에 RusAsDaemon과 이 데몬이 실행 될 주기를 입력하면 된다.

# Created by
# /usr/local/mrtg-2/bin/cfgmaker --global Workdir:/home/mrtg/data --global 'Options[_]:growright,bits' --output=/home/mrtg/cfg/test.cfg
public@123.123.123.123:::::2


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no
Workdir:/home/mrtg/data
Options[_]:growright,bits
RunAsDaemon: Yes
Interval: 3


######################################################################
# System: Cisco-Router
# Description: Cisco Internetwork Operating System Software


RunAsDaemon을 Yes로 하고, Interval에서 3으로 3분 주기로 설정을 하였다.



MRTG를 실행 시키는 방법은 아래와 같다.
[root@mrtg cfg]# mrtg /home/mrtg/cfg/test.cfg --logging /home/mrtg/log/test.log
Daemonizing MRTG ...
[root@mrtg cfg]#

MRTG가 제대로 실행되고 있는지 확인 해 본다.
[root@mrtg cfg]# ps aux | grep mrtg
avahi     2804  0.0  0.0   2592  1344 ?        Ss   11:55   0:00 avahi-daemon: running [mrtg.local]
root      6764  1.1  0.2  12316 10248 ?        Ss   16:22   0:00 /usr/bin/perl -w /usr/local/mrtg-2/bin/mrtg /home/mrtg/
cfg/test.cfg --logging /home/mrtg/log/test.log
root      6815  0.0  0.0   1844   528 pts/1    S+   16:23   0:00 grep mrtg

[root@mrtg cfg]#



서버를 재부팅 할 경우 MRTG를 실행하기 위해서는 /etc/rc.local 파일에 MRTG를 실행시키는 스크립트를 추가하면, 서버가 혹시라도 재부팅 되는 경우가 발생하더라도 자동으로 MRTG가 실행 될 것이다.

[root@mrtg cfg]# vi /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
LANG=C
/usr/local/apache/bin/apachectl start


아래와 같이 스크립트를 추가한다.

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
LANG=C
/usr/local/apache/bin/apachectl start

mrtg /home/mrtg/cfg/test.cfg --logging /home/mrtg/log/test.log





STEP 3.

MRTG로 수집한 트래픽 정보를 RRDTool에 저장을 하면 MRTG의 동작 속도를 향상 시킬 수 있으며, RRDTool의 경우 일정한 용량의 데이터로 수집하고 저장하기 때문에 서버의 용량이 크게 작용하지 않는 장점을 가지고 있다.
물론 시간이 많이 지나게되면, 처음에 수집한 데이터 값을 일정한 시간의 평균 값으로 저장하기 때문에 실제 데이터와 차이를 보이는 단점은 있다.

MRTG에서 수집한 트래픽 정보를 RRD에 저장하기 위해서 MRTG cfg 파일 내에 로그파일 형식을 RRDTool로 선언하는 항목을 추가하면된다. 또, MRTG에서 RRDTool을 이용하기 위해서는 RRDs.pm이라는 RRDTool의 perl모듈이 필요하며 RRDTool을 실행 할 수 있어야 한다.

[root@mrtg cfg]# vi test.cfg
# Created by
# /usr/local/mrtg-2/bin/cfgmaker --global Workdir:/home/mrtg/data/ --global 'Options[_]:growright,bits' --output=/home/mrtg/cfg/test.cfg
public@123.123.123.123:::::2


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no
WorkDir:/home/mrtg/data
icondir:/images/mrtg
Options[_]:growright,bits
RunAsDaemon: Yes
Interval: 3

######################################################################
# System: Cisco-Router
# Description: Cisco Internetwork Operating System Software


아래와 같이 추가한다.

# Created by
# /usr/local/mrtg-2/bin/cfgmaker --global Workdir:/home/mrtg/data/ --global 'Options[_]:growright,bits' --output=/home/mrtg/cfg/test.cfg
public@123.123.123.123:::::2


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no
WorkDir:/home/mrtg/data
icondir:/images/mrtg
Options[_]:growright,bits
RunAsDaemon: Yes
Interval: 3

PathAdd: /usr/local/rrdtool-1.2.12/bin/
LibAdd: /usr/local/rrdtool-1.2.12/lib/perl/5.8.8/i386-linux-thread-multi/
LogFormat: rrdtool

######################################################################
# System: Cisco-Router
# Description: Cisco Internetwork Operating System Software






STEP 4.

MRTG-RRD는 CGI/FastCGI로 개발된 RRDTool 형태의 데이터로부터 MRTG 그래프를 생성하는 스크립트이다.

MRTG를 이용하여 그래프를 생성하는 스크립트를 받는다.
이 스크립트는 매 5분마다 PNG파일을 생성하지 않아 MRTG를 이용한 모니터링 시스템의 성능을 향상 시킨다.

[root@mrtg cfg]#  cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget ftp://ftp.linux.cz/pub/linux/people/jan_kasprzak/mrtg-rrd/mrtg-rrd-0.7.tar.gz
[root@mrtg mrtg-rrd-0.7]# cp * /usr/local/apache/cgi-bin/
[root@mrtg cfg]# cd /usr/local/apache/cgi-bin/
[root@mrtg cgi-bin]# vi mrtg-rrd.cgi

# Location of RRDs.pm, if it is not in @INC
# use lib '/usr/lib/perl5/5.00503/i386-linux';
use RRDs;

use vars qw(@config_files @all_config_files %targets $config_time
        %directories $version $imagetype);

# EDIT THIS to reflect all your MRTG config files
BEGIN { @config_files = qw(/home/fadmin/mrtg/cfg/mrtg.cfg); }

$version = '0.7';

아래와 같이 변경한다.

# Location of RRDs.pm, if it is not in @INC
use lib '/usr/local/rrdtool-1.2.12/lib/perl/5.8.8/i386-linux-thread-multi';

use RRDs;

use vars qw(@config_files @all_config_files %targets $config_time
        %directories $version $imagetype);

# EDIT THIS to reflect all your MRTG config files
BEGIN { @config_files = qw(/home/mrtg/cfg/test.cfg); }

$version = '0.7';

RRDs.pm 모듈에 대한 경로 설정 및 mrtg.cfg 파일의 경로를 지정한 것이다.
현재 내가 설치 한 서버에서는 /usr/local/rrdtool-1.2.12/lib/perl/5.8.8/i386-linux-thread-multi에 RRDs.pm 모듈이 존재하며, cfg 파일은 /home/mrtg/cfg에 rrd 파일은 /home/mrtg/data에 마지막으로 log 파일은 /home/mrtg/log에 저장 할 것이다. BEGIN { @config_files = qw(/home/mrtg/cfg/mrtg.cfg); } 의 위치는 각자 자신이 저장할 위치에 맞춰서 저장하면 될 것이다.


이제 웹브라우저를 실행시켜 웹으로 접속을 해 보겠다.


올바른 경로로 접속을 하였지만 기대했던 그래프는 나오지 않고, Error 메시지가 우리를 반긴다.
test.cfg가 저장 된 /home/mrtg 디렉토리가 사용자만 사용 할 수 있기 때문에 현재 권한이 없다고 나오는 것이다.

[root@mrtg home]# ls -al
total 48
drwxr-xr-x  6 root    root     4096 Mar 23 13:44 .
drwxr-xr-x 23 root    root     4096 Mar 25 11:55 ..
drwx------  3 celltwo celltwo  4096 Mar 25 16:38 celltwo
drwx------  2 root    root    16384 Mar 23 10:26 lost+found
drwx------  6 mrtg    mrtg     4096 Mar 25 16:38 mrtg

[root@mrtg home]#

웹에서 디렉토리에 접근하여 볼 수 있게 접근 권한을 변경한다.

[root@mrtg home]# chmod 777 mrtg/
[root@mrtg home]# ls -al
total 48
drwxr-xr-x  6 root    root     4096 Mar 23 13:44 .
drwxr-xr-x 23 root    root     4096 Mar 25 11:55 ..
drwx------  3 celltwo celltwo  4096 Mar 25 16:38 celltwo
drwx------  2 root    root    16384 Mar 23 10:26 lost+found
drwxrwxrwx  6 mrtg    mrtg     4096 Mar 25 16:38 mrtg

[root@mrtg home]#


/home/mrtg 안에 설치 할 때 만든 cfg, data, log 디렉토리가 있을 것이다. (다르게 설치했다면, 그 설정에 맞출 것)
하위 디렉토리도 그에 맞게 설정을 변경을 하여야 한다.

[root@mrtg home]# cd mrtg/
[root@mrtg mrtg]# chmod 755 cfg
[root@mrtg mrtg]# chmod 755 log
[root@mrtg mrtg]# chmod 777 data


cfg와 log는 읽고 실행만 가능하게 해줬는데 data 디렉토리만 읽고 쓰고 실행 모든 권한을 다 줬는지 궁굼할 것이다.
MRTG가 RRDTool에서 데이터를 불러와 그래프로 표현 할 때 쓰기 권한이 없으면 그래프를 생성 할 수 없기 때문에 모든 권한을 다 열어 준 것이다.

이제 설정이 완료 되었으므로 웹브라우저를 새로고침 해 본다.


이제부터는 5분마다 그래프를 그리며 라우터의 트래픽을 보여 줄 것이다.




'Linux tools > MRTG' 카테고리의 다른 글

MRTG서버에 Weathermap 설치 및 사용하기  (0) 2010.03.26
MRTG 설치 방법  (0) 2010.03.23
블로그 이미지

쭈꾸댕이

아직 어설픈 실력으로 나름 제가 하는 것에 대한 것들을 옮기는 공간입니다. 틀린 부분도 있을 수 있으니 이 점 양해하시고, 도움이 되셨으면 좋겠네요.

,





설치 환경

OS : CentOS 5.4 i386
Web : Apache2
CGG : gcc version 4.1.2
Perl : 5.8.8


아래와 같은 라이브러리가 필요하다. 웹에서 검색하여 다운 받도록 하자.

GD-2.0.33
ZLIB-1.2.3
LIBPNG-1.2.8
FREETYPE-2.1.10
RRDTOOL-1.2.12
libart-lgpl-2.1.10


설치에 앞서 환경변수를 설정한다.

[root@mrtg ~]# BUILD_DIR=/usr/local/rrdbuild
[root@mrtg ~]# INSTALL_DIR=/usr/local/rrdtool-1.2.12
[root@mrtg ~]# export BUILD_DIR INSTALL_DIR



STEP 1.

zlib부터 설치를 시작한다.

[root@mrtg ~]# cd /usr/local
[root@mrtg local]# mkdir -p rrdbuild
[root@mrtg local]# cd rrdbuild
[root@mrtg rrdbuild]# lftpget http://google-desktop-for-linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz
[root@mrtg rrdbuild]# tar xvfz zlib-1.2.3.tar.gz
zlib/
zlib/1.2.3/
zlib/1.2.3/ChangeLog
zlib/1.2.3/FAQ
zlib/1.2.3/INDEX
zlib/1.2.3/Makefile
zlib/1.2.3/Makefile.in
zlib/1.2.3/README
zlib/1.2.3/adler32.c
zlib/1.2.3/algorithm.txt
zlib/1.2.3/compress.c
zlib/1.2.3/configure
zlib/1.2.3/crc32.c
.................... 생략 .......................
zlib/1.2.3/projects/visualc6/zlib.dsp
zlib/1.2.3/projects/visualc6/zlib.dsw
zlib/1.2.3/qnx/
zlib/1.2.3/qnx/package.qpg
zlib/1.2.3/win32/
zlib/1.2.3/win32/DLL_FAQ.txt
zlib/1.2.3/win32/Makefile.bor
zlib/1.2.3/win32/Makefile.emx
zlib/1.2.3/win32/Makefile.gcc
zlib/1.2.3/win32/Makefile.msc
zlib/1.2.3/win32/VisualC.txt
zlib/1.2.3/win32/zlib.def
zlib/1.2.3/win32/zlib1.rc

[root@mrtg rrdbuild]# CFLAGS="-O3 -fPIC"
[root@mrtg rrdbuild]# export CFLAGS
[root@mrtg rrdbuild]# cd zlib
[root@mrtg zlib]# cd 1.2.3
[root@mrtg 1.2.3]# ./configure --prefix=$BUILD_DIR/lb
Checking for gcc...
Building static library libz.a version 1.2.3 with gcc.
Checking for unistd.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for errno.h... Yes.
Checking for mmap support... Yes.
[root@mrtg 1.2.3]# make
gcc -O3 -fPIC -DUSE_MMAP   -c -o example.o example.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o adler32.o adler32.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o compress.o compress.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o crc32.o crc32.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o gzio.o gzio.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o uncompr.o uncompr.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o deflate.o deflate.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o trees.o trees.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o zutil.o zutil.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inflate.o inflate.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o infback.o infback.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inftrees.o inftrees.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inffast.o inffast.c
ar rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o
gcc -O3 -fPIC -DUSE_MMAP -o example example.o -L. libz.a
gcc -O3 -fPIC -DUSE_MMAP   -c -o minigzip.o minigzip.c
gcc -O3 -fPIC -DUSE_MMAP -o minigzip minigzip.o -L. libz.a

[root@mrtg 1.2.3]# make install
cp zlib.h zconf.h /usr/local/rrdbuild/lb/include
chmod 644 /usr/local/rrdbuild/lb/include/zlib.h /usr/local/rrdbuild/lb/include/zconf.h
cp libz.a /usr/local/rrdbuild/lb/lib
cd /usr/local/rrdbuild/lb/lib; chmod 755 libz.a
cd /usr/local/rrdbuild/lb/lib; if test -f libz.so.1.2.3; then \
          rm -f libz.so libz.so.1; \
          ln -s libz.so.1.2.3 libz.so; \
          ln -s libz.so.1.2.3 libz.so.1; \
          (ldconfig || true)  >/dev/null 2>&1; \
        fi
cp zlib.3 /usr/local/rrdbuild/lb/share/man/man3
chmod 644 /usr/local/rrdbuild/lb/share/man/man3/zlib.3

[root@mrtg 1.2.3]#

zlib 설치가 완료 되었다.




STEP 2.

libpng를 설치한다.

[root@mrtg rrdbuild]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget ftp://ftp.kr.freebsd.org/pub/xorg/X11R7.0/src/extras/libpng-1.2.8-config.tar.gz
[root@mrtg rrdbuild]# tar xvfz libpng-1.2.8-config.tar.gz
libpng-1.2.8-config/
libpng-1.2.8-config/contrib/
libpng-1.2.8-config/contrib/gregbook/
libpng-1.2.8-config/contrib/gregbook/writepng.h
libpng-1.2.8-config/contrib/gregbook/Makefile.sgi
libpng-1.2.8-config/contrib/gregbook/Makefile.unx
libpng-1.2.8-config/contrib/gregbook/Makefile.w32
libpng-1.2.8-config/contrib/gregbook/README
libpng-1.2.8-config/contrib/gregbook/makevms.com
libpng-1.2.8-config/contrib/gregbook/readpng.c
libpng-1.2.8-config/contrib/gregbook/readpng.h
libpng-1.2.8-config/contrib/gregbook/readpng2.c
libpng-1.2.8-config/contrib/gregbook/readpng2.h
libpng-1.2.8-config/contrib/gregbook/rpng-win.c
libpng-1.2.8-config/contrib/gregbook/rpng-x.c
libpng-1.2.8-config/contrib/gregbook/rpng2-win.c
libpng-1.2.8-config/contrib/gregbook/rpng2-x.c
..................... 생략 ...................
libpng-1.2.8-config/autogen.sh
libpng-1.2.8-config/config.guess
libpng-1.2.8-config/config.h.in
libpng-1.2.8-config/config.sub
libpng-1.2.8-config/configure.ac
libpng-1.2.8-config/depcomp
libpng-1.2.8-config/install-sh
libpng-1.2.8-config/missing
libpng-1.2.8-config/ltmain.sh
libpng-1.2.8-config/mkinstalldirs
libpng-1.2.8-config/test-pngtest.sh

[root@mrtg rrdbuild]# CPPFLAGS=-I$BUILD_DIR/lb/include
[root@mrtg rrdbuild]# LDFLAGS=-L$BUILD_DIR/lb/lib
[root@mrtg rrdbuild]# CFLAGS="-O3 -fPIC"
[root@mrtg rrdbuild]# export CPPFLAGS LDFLAGS CFLAGS
[root@mrtg rrdbuild]# cd libpng-1.2.8-config
[root@mrtg libpng-1.2.8-config]# ./configure --prefix=$BUILD_DIR/lb --disable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
..................... 생략 ......................
checking for memset... yes
checking for pow... no
checking for strrchr... yes
checking for sqrt... no
checking for sqrt in -lm... yes
checking for zlibVersion in -lz... yes
checking pkgconfig directory... ${prefix}/lib/pkgconfig
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands

[root@mrtg libpng-1.2.8-config]# make
make  all-am
make[1]: Entering directory `/usr/local/rrdbuild/libpng-1.2.8-config'
if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.     -O3 -fPIC -MT png.lo -MD -MP -MF ".deps/png.Tpo" \
          -c -o png.lo `test -f 'png.c' || echo './'`png.c; \
        then mv ".deps/png.Tpo" ".deps/png.Plo"; \
........................ 생략 ......................
( cat ./scripts/libpng-config-head.in; \
        echo prefix=\"/usr/local/rrdbuild/lb\"; \
        echo I_opts=\"-I/usr/local/rrdbuild/lb/include\"; \
        echo L_opts=\"-L/usr/local/rrdbuild/lb/lib\"; \
        echo R_opts=\"-Wl,-rpath,/usr/local/rrdbuild/lb/lib\"; \
        echo libs=\"-lpng12 -lz -lm\"; \
        cat ./scripts/libpng-config-body.in ) > libpng-config
cp libpng-config libpng12-config
make[1]: Leaving directory `/usr/local/rrdbuild/libpng-1.2.8-config'

[root@mrtg libpng-1.2.8-config]# make install
make[1]: Entering directory `/usr/local/rrdbuild/libpng-1.2.8-config'
/bin/sh ./mkinstalldirs /usr/local/rrdbuild/lb/bin
mkdir -p -- /usr/local/rrdbuild/lb/bin
 /usr/bin/install -c libpng-config /usr/local/rrdbuild/lb/bin/libpng-config
 /usr/bin/install -c libpng12-config /usr/local/rrdbuild/lb/bin/libpng12-config
/bin/sh ./mkinstalldirs /usr/local/rrdbuild/lb/lib
 /bin/sh ./libtool --mode=install /usr/bin/install -c  libpng12.la /usr/local/rrdbuild/lb/lib/libpng12.la
/usr/bin/install -c .libs/libpng12.lai /usr/local/rrdbuild/lb/lib/libpng12.la
......................... 생략 .........................
mkdir -p -- /usr/local/rrdbuild/lb/man/man5
 /usr/bin/install -c -m 644 ./png.5 /usr/local/rrdbuild/lb/man/man5/png.5
/bin/sh ./mkinstalldirs /usr/local/rrdbuild/lb/include/libpng
mkdir -p -- /usr/local/rrdbuild/lb/include/libpng
 /usr/bin/install -c -m 644 png.h /usr/local/rrdbuild/lb/include/libpng/png.h
 /usr/bin/install -c -m 644 pngconf.h /usr/local/rrdbuild/lb/include/libpng/pngconf.h
make[1]: Leaving directory `/usr/local/rrdbuild/libpng-1.2.8-config'
[root@mrtg libpng-1.2.8-config]#

libpng 설치가 완료 되었다.




STEP 3.

freetype2를 설치한다.

[root@mrtg libpng-1.2.8-config]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget ftp://ftp.netlabs.org/pub/Cairo/cairo-1.0.2-2005.11.01/cairo-1.0.2-os2-deps/freetype-2.1.10.tar.gz
[root@mrtg freetype-2.1.10]# tar xvfz freetype-2.1.10.tar.gz
....................... 생략 .........................
freetype-2.1.10/src/type42/type42.c
freetype-2.1.10/src/winfonts/
freetype-2.1.10/src/winfonts/fnterrs.h
freetype-2.1.10/src/winfonts/Jamfile
freetype-2.1.10/src/winfonts/module.mk
freetype-2.1.10/src/winfonts/rules.mk
freetype-2.1.10/src/winfonts/winfnt.c
freetype-2.1.10/src/winfonts/winfnt.h

[root@mrtg rrdbuild]# CPPFLAGS=-I$BUILD_DIR/lb/include
[root@mrtg rrdbuild]# LDFLAGS=-L$BUILD_DIR/lb/lib
[root@mrtg rrdbuild]# CFLAGS="-O3 -fPIC"
[root@mrtg rrdbuild]# export CPPFLAGS LDFLAGS CFLAGS
[root@mrtg rrdbuild]# cd freetype-2.1.10
[root@mrtg freetype-2.1.10]# ./configure --prefix=$BUILD_DIR/lb --disable-shared
cd builds/unix; ./configure --prefix=/usr/local/rrdbuild/lb --disable-shared
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
..................... 생략 .......................
If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type `make' again to build the library,
or `make refdoc' to build the API reference (the latter needs python).

make: Nothing to be done for `unix'.
[root@mrtg freetype-2.1.10]# set env GNUMAKE /usr/local/bin/make
[root@mrtg freetype-2.1.10]# ./configure --prefix=$BUILD_DIR/lb --disable-shared
cd builds/unix; ./configure --prefix=/usr/local/rrdbuild/lb --disable-shared
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
........................ 생략 .........................
  configuration rules         ./builds/unix/unix.mk

If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.

Otherwise, simply type `make' again to build the library,
or `make refdoc' to build the API reference (the latter needs python).

make: Nothing to be done for `unix'.
[root@mrtg freetype-2.1.10]# make
.................... 생략 ...................
2.1.10/objs/ftlzw.o /usr/local/rrdbuild/freetype-2.1.10/objs/otvalid.o /usr/local/rrdbuild/freetype-2.1.10/objs/pcf.o /usr/local/rrdbuild/freetype-2.1.10/objs/pfr.o /usr/local/rrdbuild/freetype-2.1.10/objs/psaux.o /usr/local/rrdbuild/freetype-2.1.10/objs/pshinter.o /usr/local/rrdbuild/freetype-2.1.10/objs/psnames.o /usr/local/rrdbuild/freetype-2.1.10/objs/raster.o /usr/local/rrdbuild/freetype-2.1.10/objs/sfnt.o /usr/local/rrdbuild/freetype-2.1.10/objs/smooth.o /usr/local/rrdbuild/freetype-2.1.10/objs/truetype.o /usr/local/rrdbuild/freetype-2.1.10/objs/type1.o /usr/local/rrdbuild/freetype-2.1.10/objs/type42.o /usr/local/rrdbuild/freetype-2.1.10/objs/winfnt.o
ranlib /usr/local/rrdbuild/freetype-2.1.10/objs/.libs/libfreetype.a
creating /usr/local/rrdbuild/freetype-2.1.10/objs/libfreetype.la
(cd /usr/local/rrdbuild/freetype-2.1.10/objs/.libs && rm -f libfreetype.la && ln -s ../libfreetype.la libfreetype.la)

[root@mrtg freetype-2.1.10]# make install
/usr/bin/install -c -m 644 ./builds/unix/ftconfig.h \
          /usr/local/rrdbuild/lb/include/freetype2/freetype/config/ftconfig.h
/usr/bin/install -c -m 755 ./builds/unix/freetype-config \
          /usr/local/rrdbuild/lb/bin/freetype-config
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4 \
          /usr/local/rrdbuild/lb/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc \
          /usr/local/rrdbuild/lb/lib/pkgconfig/freetype2.pc

[root@mrtg freetype-2.1.10]#

freetype2 설치가 완료 되었다.




STEP 4.

libart-lgpl을 설치한다.

[root@mrtg freetype-2.1.10]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget http://ftp.se.debian.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.17.tar.gz
[root@mrtg rrdbuild]# tar xvfz libart_lgpl-2.3.17.tar.gz
libart_lgpl-2.3.17/
libart_lgpl-2.3.17/art_svp_vpath.h
libart_lgpl-2.3.17/art_svp_vpath_stroke.c
libart_lgpl-2.3.17/art_rgb_affine.c
libart_lgpl-2.3.17/art_svp_ops.h
libart_lgpl-2.3.17/art_uta_vpath.h
.................. 생략 ....................
libart_lgpl-2.3.17/art_render_gradient.c
libart_lgpl-2.3.17/art_rgb_affine.h
libart_lgpl-2.3.17/art_misc.c
libart_lgpl-2.3.17/art_render.c
libart_lgpl-2.3.17/art_rgb_pixbuf_affine.c

[root@mrtg rrdbuild]# cd libart_lgpl-2.3.17
[root@mrtg libart_lgpl-2.3.17]# CFLAGS="-O3 -fPIC"
[root@mrtg libart_lgpl-2.3.17]# export CPPFLAGS
[root@mrtg libart_lgpl-2.3.17]# ./configure --prefix=$BUILD_DIR/lb --disable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... yes
checking for working aclocal-1.4... found
................... 생략 .....................
config.status: creating libart-2.0.pc
config.status: creating libart-2.0-uninstalled.pc
config.status: creating libart-zip
config.status: creating config.h
config.status: executing default-1 commands
config.status: executing default commands
[root@mrtg libart_lgpl-2.3.17]# make

.................... 생략 ......................
testart.c:520: warning: ?utput_svp_ppm?defined but not used
/bin/sh ./libtool --mode=link gcc  -O3 -fPIC -Wall -Wmissing-prototypes -L/usr/local/rrdbuild/lb/lib -o testart  testart.o ./libart_lgpl_2.la -lm
gcc -O3 -fPIC -Wall -Wmissing-prototypes -o testart testart.o  -L/usr/local/rrdbuild/lb/lib ./.libs/libart_lgpl_2.a -lm
gcc -DHAVE_CONFIG_H -I. -I. -I. -I. -I. -DLIBART_COMPILATION    -O3 -fPIC -Wall -Wmissing-prototypes -c testuta.c
/bin/sh ./libtool --mode=link gcc  -O3 -fPIC -Wall -Wmissing-prototypes -L/usr/local/rrdbuild/lb/lib -o testuta  testuta.o ./libart_lgpl_2.la -lm
gcc -O3 -fPIC -Wall -Wmissing-prototypes -o testuta testuta.o  -L/usr/local/rrdbuild/lb/lib ./.libs/libart_lgpl_2.a -lm
cp -f libart-config libart2-config

[root@mrtg libart_lgpl-2.3.17]# make install
make[1]: Entering directory `/usr/local/rrdbuild/libart_lgpl-2.3.17'
/bin/sh ./mkinstalldirs /usr/local/rrdbuild/lb/lib
/bin/sh ./libtool  --mode=install /usr/bin/install -c libart_lgpl_2.la /usr/local/rrdbuild/lb/lib/libart_lgpl_2.la
/usr/bin/install -c .libs/libart_lgpl_2.lai /usr/local/rrdbuild/lb/lib/libart_lgpl_2.la
/usr/bin/install -c .libs/libart_lgpl_2.a /usr/local/rrdbuild/lb/lib/libart_lgpl_2.a
ranlib /usr/local/rrdbuild/lb/lib/libart_lgpl_2.a
chmod 644 /usr/local/rrdbuild/lb/lib/libart_lgpl_2.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/rrdbuild/lb/lib
....................... 생략 .....................
 /usr/bin/install -c -m 644 art_vpath_bpath.h /usr/local/rrdbuild/lb/include/libart-2.0/libart_lgpl/art_vpath_bpath.h
 /usr/bin/install -c -m 644 art_vpath_dash.h /usr/local/rrdbuild/lb/include/libart-2.0/libart_lgpl/art_vpath_dash.h
 /usr/bin/install -c -m 644 art_vpath_svp.h /usr/local/rrdbuild/lb/include/libart-2.0/libart_lgpl/art_vpath_svp.h
 /usr/bin/install -c -m 644 libart.h /usr/local/rrdbuild/lb/include/libart-2.0/libart_lgpl/libart.h
 /usr/bin/install -c -m 644 libart-features.h /usr/local/rrdbuild/lb/include/libart-2.0/libart_lgpl/libart-features.h
make[1]: Leaving directory `/usr/local/rrdbuild/libart_lgpl-2.3.17'

[root@mrtg libart_lgpl-2.3.17]#

지금까지 설치한 라이브러리는 모두 static 형태이므로 라이브러리를 사용하기 위하여 ranlib을 사용한다.

[root@mrtg libart_lgpl-2.3.17]# ranlib $BUILD_DIR/lb/lib/*.a

libart-lgpl 설치가 완료 되었다.





STEP 5.

gd를 설치 한다.

[root@mrtg libart_lgpl-2.3.17]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
[root@mrtg rrdbuild]# tar xvfz gd-2.0.33.tar.gz                              
gd-2.0.33/
gd-2.0.33/config/
gd-2.0.33/config/Makefile.am
gd-2.0.33/config/Makefile.in
............................ 생략 .............................
gd-2.0.33/test/Makefile.in
gd-2.0.33/test/gdtest.gd2
gd-2.0.33/test/gdtest.png
gd-2.0.33/test/gdtest_200_300_150_100.png
gd-2.0.33/test/gdtest_merge.png
gd-2.0.33/test/gdtest_wbmp_to_png.png

[root@mrtg rrdbuild]# cd gd-2.0.33
[root@mrtg gd-2.0.33]# CPPFLAGS=-I$BUILD_DIR/lb/include
[root@mrtg gd-2.0.33]# export CPPFLAGS
[root@mrtg gd-2.0.33]# ./configure --prefix=$BUILD_DIR/lb --disable-shared
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
........................ 생략 ......................
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config/Makefile
config.status: creating config/gdlib-config
config.status: creating test/Makefile
config.status: creating config.h
config.status: executing depfiles commands

[root@mrtg gd-2.0.33]# make
make  all-recursive
make[1]: Entering directory `/usr/local/rrdbuild/gd-2.0.33'
Making all in config
make[2]: Entering directory `/usr/local/rrdbuild/gd-2.0.33/config'
make[2]: Nothing to be done for `all'.
................... 생략 ................
gd_png.c:741: error: expected ')' before 'gdMalloc'
gd_png.c:798: error: expected ')' before 'gdMalloc'
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/usr/local/rrdbuild/gd-2.0.33'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/rrdbuild/gd-2.0.33'
make: *** [all] Error 2

[root@mrtg gd-2.0.33]# make install
Making install in config
make[1]: Entering directory `/usr/local/rrdbuild/gd-2.0.33/config'
make[2]: Entering directory `/usr/local/rrdbuild/gd-2.0.33/config'
test -z "/usr/local/rrdbuild/lb/bin" || mkdir -p -- "/usr/local/rrdbuild/lb/bin"
 /usr/bin/install -c 'gdlib-config' '/usr/local/rrdbuild/lb/bin/gdlib-config'
..................... 생략 ..................
gd_png.c:688: error: 'palette' undeclared (first use in this function)
gd_png.c:719: error: 'png_bytep' undeclared (first use in this function)
gd_png.c:719: error: 'row_pointers' undeclared (first use in this function)
gd_png.c:725: error: 'prow_pointers' undeclared (first use in this function)
gd_png.c:741: error: expected ')' before 'gdMalloc'
gd_png.c:798: error: expected ')' before 'gdMalloc'
make[1]: *** [gd_png.lo] Error 1
make[1]: Leaving directory `/usr/local/rrdbuild/gd-2.0.33'
make: *** [install-recursive] Error 1

[root@mrtg gd-2.0.33]#

gd 설치가 완료 되었다.

GD 컴파일시 위에서 설치한 라이브러리가 인식되는지 반드시 확인한다. freetype을 인식하지 못하는 경우가 있는데, 이때는 PATH에 /usr/local/rrdbuild/lb/bin or /usr/local/rrdbuild/lib/include를 추가한다.

[root@mrtg gd-2.0.33]# vi ~/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME


아래와 같이 변경한다.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/rrdbuild/lb/bin:/usr/local/rrdbuild/lib/include

export PATH
unset USERNAME


변경된 PATH를 적용 시키려면 아래와 같이 명령어를 입력한다.

[root@mrtg gd-2.0.33]# source ~/.bash_profile




STEP 6.

RRDTOOL을 설치한다.

[root@mrtg gd-2.0.33]# IR=-I$BUILD_DIR/lb/include
[root@mrtg gd-2.0.33]# CPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"
[root@mrtg gd-2.0.33]# LDFLAGS="-L$BUILD_DIR/lb/lib"
[root@mrtg gd-2.0.33]# CFLAGS=-O3
[root@mrtg gd-2.0.33]# export CPPFLAGS LDFLAGS CFLAGS
[root@mrtg gd-2.0.33]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget ftp://ftp.free.fr/.mirrors1/ftp.netbsd.org/packages/distfiles/rrdtool-1.2.12.tar.gz
[root@mrtg rrdbuild]# tar xvfz rrdtool-1.2.12.tar.gz                                                                   
rrdtool-1.2.12/bindings/tcl/README
rrdtool-1.2.12/bindings/tcl/Makefile.am
rrdtool-1.2.12/bindings/tcl/Makefile.in
rrdtool-1.2.12/bindings/tcl/ifOctets.tcl.in
rrdtool-1.2.12/bindings/tcl/tclrrd.c
................... 생략 .....................
rrdtool-1.2.12/doc/rrdgraph_data.txt
rrdtool-1.2.12/doc/rrdresize.txt
rrdtool-1.2.12/doc/rrdtutorial.txt
rrdtool-1.2.12/doc/rrdtool-dump.dtd
rrdtool-1.2.12/doc/rrdtool-xport.dtd
[root@mrtg rrdbuild]# cd rrdtool-1.2.12
[root@mrtg rrdtool-1.2.12]#
[root@mrtg rrdtool-1.2.12]# ./configure --prefix=$INSTALL_DIR --disable-python --disable-tcl
..................... 생략 .....................
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default commands
checking in... and out again
ordering CD from
http://people.ee.ethz.ch/~oetiker/wish .... just kidding ;-)

----------------------------------------------------------------
Config is DONE!

          With MMAP IO: yes
          Perl Modules: perl_piped perl_shared
           Perl Binary: /usr/bin/perl
          Perl Version: 5.8.8
          Perl Options: PREFIX=/usr/local/rrdtool-1.2.12 LIB=/usr/local/rrdtool-1.2.12/lib/perl/5.8.8
    Build Tcl Bindings: no
 Build Python Bindings: no
          Build rrdcgi: yes
       Build librrd MT: yes


Type 'make' to compile the software and use 'make install' to
install everything to: /usr/local/rrdtool-1.2.12.

       ... that wishlist is NO JOKE. If you find RRDtool useful
make me happy. Go to
http://people.ee.ethz.ch/oetiker/wish and
place an order.

                               -- Tobi Oetiker <tobi@oetiker.ch>
----------------------------------------------------------------

[root@mrtg rrdtool-1.2.12]# make clean
Making clean in examples
make[1]: Entering directory `/usr/local/rrdbuild/rrdtool-1.2.12/examples'
rm -rf .libs _libs
rm -f *.lo
make[1]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12/examples'
.................... 생략 ........................
make[1]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12/src'
Making clean in .
make[1]: Entering directory `/usr/local/rrdbuild/rrdtool-1.2.12'
test -z "config.cache" || rm -f config.cache
rm -rf .libs _libs
rm -f *.lo
make[1]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12'

[root@mrtg rrdtool-1.2.12]# make
.................... 생략 ........................
pod2html --infile=rrdtutorial.pod --outfile=rrdtutorial.html --noindex --htmlroot=. --podpath=. --title=rrdtutorial
ln -s ../bindings/perl-shared/RRDs.pm RRDs.pod
pod2html --infile=RRDs.pod --outfile=RRDs.html --noindex --htmlroot=. --podpath=. --title=RRDs
ln -s ../bindings/perl-piped/RRDp.pm RRDp.pod
pod2html --infile=RRDp.pod --outfile=RRDp.html --noindex --htmlroot=. --podpath=. --title=RRDp
make[2]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12/doc'
Making all in examples
make[2]: Entering directory `/usr/local/rrdbuild/rrdtool-1.2.12/examples'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12/examples'
make[2]: Entering directory `/usr/local/rrdbuild/rrdtool-1.2.12'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12'
make[1]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12'

[root@mrtg rrdtool-1.2.12]# make install
.................... 생략 ........................
 /usr/bin/install -c 'cgi-demo.cgi' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/cgi-demo.cgi'
 /usr/bin/install -c 'piped-demo.pl' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/piped-demo.pl'
 /usr/bin/install -c 'shared-demo.pl' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/shared-demo.pl'
 /usr/bin/install -c 'stripes.pl' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/stripes.pl'
 /usr/bin/install -c 'bigtops.pl' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/bigtops.pl'
 /usr/bin/install -c 'minmax.pl' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/minmax.pl'
 /usr/bin/install -c '4charts.pl' '/usr/local/rrdtool-1.2.12/share/rrdtool/examples/4charts.pl'
make[2]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12/examples'
make[1]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12/examples'
make[1]: Entering directory `/usr/local/rrdbuild/rrdtool-1.2.12'
make[2]: Entering directory `/usr/local/rrdbuild/rrdtool-1.2.12'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12'
make[1]: Leaving directory `/usr/local/rrdbuild/rrdtool-1.2.12'

[root@mrtg rrdtool-1.2.12]#





STEP 7.

MRTG를 설치 한다.

[root@mrtg rrdtool-1.2.12]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget ftp://ftp.ps.pl/dsk0/ftp.freebsd.org/FreeBSD/ports/distfiles/mrtg-2.12.2.tar.gz
[root@mrtg mrtg-2.12.2]# tar xvfz mrtg-2.12.2.tar.gz
....................... 생략 ........................
mrtg-2.12.2/doc/mrtg-squid.1
mrtg-2.12.2/doc/mrtg-squid.html
mrtg-2.12.2/doc/mrtg-squid.pod
mrtg-2.12.2/doc/mrtg-squid.txt
mrtg-2.12.2/doc/mrtg-unix-guide.1
mrtg-2.12.2/doc/mrtg-unix-guide.html
mrtg-2.12.2/doc/mrtg-unix-guide.pod
mrtg-2.12.2/doc/mrtg-unix-guide.txt
mrtg-2.12.2/doc/mrtg-webserver.1
mrtg-2.12.2/doc/mrtg-webserver.html
mrtg-2.12.2/doc/mrtg-webserver.pod
mrtg-2.12.2/doc/mrtg-webserver.txt
mrtg-2.12.2/doc/mrtg.1
mrtg-2.12.2/doc/mrtg.html
mrtg-2.12.2/doc/mrtg.pod
mrtg-2.12.2/doc/mrtg.txt

[root@mrtg rrdbuild]# cd mrtg-2.12.2
[root@mrtg mrtg-2.12.2]# ./configure --prefix=/usr/local/mrtg-2  --with-gd=/usr/loca/rrdbuild/lb --with-z=/usr/local/rrdbuild/lb --with-png=/usr/local/rrdbuild/lb
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
....................... 생략 ........................
** Ooops, one of many bad things happened:

   a)  You don't have the GD library installed.
       Get it from
http://www.boutell.com, compile it and
       use either --with-gd-lib=DIR and --with-gd-inc=DIR to specify
       its location. You might also have to use --with-z-inc,
             --with-z-lib and --with-png-inc, --with-png-lib for gd
             versions 1.6 and higher.  Check config.log for more
       information on the problem.

   b)  You have the GD library installed, but not the gd.h
       header file.  Download the source (see above) and use
       --with-gd-inc=DIR to specify where the file can be found.

   c)  You have the library and the header file installed, but
       you also have a shared GD library in the same directory.
       Remove the shared library files and/or links (e.g.
       libgd.so.2.0.0, libgd.so and libgd.so.2).  This is especially
             likely if you're using a recent (post 1.8.4) version of GD
       and didn't configure it with --disable-shared.

   d)  You have gd library installed and also it's headers, but you are
       missing libpng (and headers) or freetype (and headers)
       (mrtg does not use freetype, but if your copy of gd is precompiled
       against it, you have to install it ...

   Consider following the instructions in doc/mrtg-unix-guide.txt
[root@mrtg mrtg-2.12.2]# --with-z=/usr/local/rrdbuild/lb  -with-png=/usr/local/rrdbuild/lb
-bash: --with-z=/usr/local/rrdbuild/lb: No such file or directory

[root@mrtg mrtg-2.12.2]#

gd관련 라이브러리가 설치되지 않아서 mrtg를 설치 할 수 없으므로, 관련 라이브러리를 yum을 통해 설치한다.

[root@mrtg mrtg-2.12.2]# yum -y install gd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons:
ftp.daum.net
 * base: ftp.daum.net
 * extras: ftp.daum.net
 * updates: ftp.daum.net
addons                                                                                      |  951 B     00:00    
base                                                                                      | 2.1 kB     00:00    
extras                                                                                      | 2.1 kB     00:00    
updates                                                                                      | 1.9 kB     00:00    
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gd-devel.i386 0:2.0.33-9.4.el5_4.2 set to be updated
--> Processing Dependency: gd = 2.0.33-9.4.el5_4.2 for package: gd-devel
--> Processing Dependency: freetype-devel for package: gd-devel
--> Processing Dependency: libpng-devel for package: gd-devel
--> Processing Dependency: libXpm-devel for package: gd-devel
--> Processing Dependency: libX11-devel for package: gd-devel
--> Processing Dependency: libjpeg-devel for package: gd-devel
--> Processing Dependency: fontconfig-devel for package: gd-devel
--> Running transaction check
---> Package fontconfig-devel.i386 0:2.4.1-7.el5 set to be updated
---> Package freetype-devel.i386 0:2.2.1-21.el5_3 set to be updated
---> Package gd.i386 0:2.0.33-9.4.el5_4.2 set to be updated
---> Package libX11-devel.i386 0:1.0.3-11.el5 set to be updated
--> Processing Dependency: xorg-x11-proto-devel >= 7.1-2 for package: libX11-devel
--> Processing Dependency: libXau-devel for package: libX11-devel
--> Processing Dependency: libXdmcp-devel for package: libX11-devel
---> Package libXpm-devel.i386 0:3.5.5-3 set to be updated
---> Package libjpeg-devel.i386 0:6b-37 set to be updated
---> Package libpng-devel.i386 2:1.2.10-7.1.el5_3.2 set to be updated
--> Running transaction check
---> Package libXau-devel.i386 0:1.0.1-3.1 set to be updated
---> Package libXdmcp-devel.i386 0:1.0.1-2.1 set to be updated
---> Package xorg-x11-proto-devel.i386 0:7.1-13.el5 set to be updated
--> Processing Dependency: mesa-libGL-devel for package: xorg-x11-proto-devel
--> Running transaction check
---> Package mesa-libGL-devel.i386 0:6.5.1-7.7.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package                       Arch                             Version                          Repository                            Size
===========================================================================================================
Installing:
 gd-devel                       i386                       2.0.33-9.4.el5_4.2                      updates                               97 k
Installing for dependencies:
 fontconfig-devel             i386                            2.4.1-7.el5                             base                                168 k
 freetype-devel               i386                            2.2.1-21.el5_3                         base                                146 k
 libX11-devel                  i386                            1.0.3-11.el5                            base                                661 k
 libXau-devel                  i386                             1.0.1-3.1                              base                                 11 k
 libXdmcp-devel             i386                             1.0.1-2.1                               base                                7.5 k
 libXpm-devel                 i386                              3.5.5-3                                base                                31 k
 libjpeg-devel                 i386                               6b-37                                 base                               105 k
 libpng-devel                  i386                       2:1.2.10-7.1.el5_3.2                      base                               181 k
 mesa-libGL-devel         i386                             6.5.1-7.7.el5                          base                               466 k
 xorg-x11-proto-devel     i386                              7.1-13.el5                             base                              247 k
Updating for dependencies:
 gd                       i386                                 2.0.33-9.4.el5_4.2                      updates                            154 k

Transaction Summary
===================================================================================================================================================================================================================================================================================
Install     11 Package(s)        
Update       1 Package(s)        
Remove       0 Package(s)        

Total download size: 2.2 M
Downloading Packages:
(1/12): libXdmcp-devel-1.0.1-2.1.i386.rpm                                                                           | 7.5 kB     00:00    
(2/12): libXau-devel-1.0.1-3.1.i386.rpm                                                                               |  11 kB     00:00    
(3/12): libXpm-devel-3.5.5-3.i386.rpm                                                                                 |  31 kB     00:00    
(4/12): gd-devel-2.0.33-9.4.el5_4.2.i386.rpm                                                                         |  97 kB     00:00    
(5/12): libjpeg-devel-6b-37.i386.rpm                                                                                   | 105 kB     00:00    
(6/12): freetype-devel-2.2.1-21.el5_3.i386.rpm                                                                      | 146 kB     00:00    
(7/12): gd-2.0.33-9.4.el5_4.2.i386.rpm                                                                                 | 154 kB     00:00    
(8/12): fontconfig-devel-2.4.1-7.el5.i386.rpm                                                                        | 168 kB     00:00    
(9/12): libpng-devel-1.2.10-7.1.el5_3.2.i386.rpm                                                                    | 181 kB     00:00    
(10/12): xorg-x11-proto-devel-7.1-13.el5.i386.rpm                                                                | 247 kB     00:00    
(11/12): mesa-libGL-devel-6.5.1-7.7.el5.i386.rpm                                                                | 466 kB     00:00    
(12/12): libX11-devel-1.0.3-11.el5.i386.rpm                                                                          | 661 kB     00:00    
------------------------------------------------------------------------------------------------------------Total                                                                                                                1.6 MB/s | 2.2 MB     00:01    
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
base/gpgkey                                                                                                                   | 1.5 kB     00:00    
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <
centos-5-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : freetype-devel                                                                                               1/13
  Installing     : fontconfig-devel                                                                                             2/13
  Installing     : libpng-devel                                                                                                  3/13
  Installing     : libXau-devel                                                                                                  4/13
  Installing     : libjpeg-devel                                                                                                  5/13
  Updating       : gd                                                                                                              6/13
  Installing     : xorg-x11-proto-devel                                                                                      7/13
  Installing     : libXdmcp-devel                                                                                              8/13
  Installing     : libX11-devel                                                                                                   9/13
  Installing     : mesa-libGL-devel                                                                                          10/13
  Installing     : libXpm-devel                                                                                                11/13
  Installing     : gd-devel                                                                                                      12/13
  Cleanup        : gd                                                                                                             13/13

Installed:
  gd-devel.i386 0:2.0.33-9.4.el5_4.2
Dependency Installed:
  fontconfig-devel.i386 0:2.4.1-7.el5    freetype-devel.i386 0:2.2.1-21.el5_3    libX11-devel.i386 0:1.0.3-11.el5  libXau-devel.i386 0:1.0.1-3.1  libXdmcp-devel.i386 0:1.0.1-2.1  libXpm-devel.i386 0:3.5.5-3  libjpeg-devel.i386 0:6b-37  libpng-devel.i386 2:1.2.10-7.1.el5_3.2
  mesa-libGL-devel.i386 0:6.5.1-7.7.el5  xorg-x11-proto-devel.i386 0:7.1-13.el5

Dependency Updated:
  gd.i386 0:2.0.33-9.4.el5_4.2                                                                                                                                                                                                                                                    

Complete!
[root@mrtg mrtg-2.12.2]#

gd 관련 라이브러리를 설치 하였으므로, mrtg를 다시 설치 해 본다.

[root@mrtg mrtg-2.12.2]# ./configure --prefix=/usr/local/mrtg-2  --with-gd=/usr/loca/rrdbuild/lb --with-z=/usr/local/rrdbuild/lb --with-png=/usr/local/rrdbuild/lb
........................ 생략 ........................
checking for gdImagePng_jpg in -lgd... no
checking for gdImagePng_jpg_ft in -lgd... no
checking for gdImageGd in -lgd... yes
checking gd.h usability... yes
checking gd.h presence... yes
checking for gd.h... yes
checking the weather... (cached) it's fine
checking if we can use GCC-specific compiler options... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
ordering CD from
http://people.ee.ethz.ch/~oetiker/wish .... just kidding ;-)

----------------------------------------------------------------
Config is DONE!

Type 'make' to compile the software

       ... that wishlist mentioned above does really exist. So if
you feel like showing your appreciation for MRTG, this is the
place to go. I just love CDs and DVDs

                            -- Tobi Oetiker <oetiker@ee.ethz.ch>
----------------------------------------------------------------
[root@mrtg mrtg-2.12.2]# make
gcc -I/usr/local/rrdbuild/lb/include -I/usr/local/rrdbuild/lb/include/libart-2.0 -I/usr/local/rrdbuild/lb/include/freetype2 -I/usr/local/rrdbuild/lb/include/libpng -I/usr/loca/rrdbuild/lb -I/usr/local/rrdbuild/lb -I/usr/local/rrdbuild/lb -DGFORM_GD=gdImagePng -O3 -Wall -Wpointer-arith -Wcast-align -Wmissing-declarations -Wnested-externs -Winline -W -DHAVE_CONFIG_H -c ./src/rateup.c -o bin/rateup.o
./src/rateup.c: In function ?mage?
./src/rateup.c:1142: warning: pointer targets in passing argument 5 of ?dImageString?differ in signedness
LD_RUN_PATH=/usr/local/rrdbuild/lb:/usr/local/rrdbuild/lb:/usr/loca/rrdbuild/lb gcc bin/rateup.o -o bin/rateup -L/usr/local/rrdbuild/lb/lib -L/usr/loca/rrdbuild/lb -L/usr/local/rrdbuild/lb -L/usr/local/rrdbuild/lb  -Wl,-Bstatic -lgd -lpng -lz -Wl,-Bdynamic  -lm
/usr/bin/perl -0777 -p -i~ -e
's@^#!\s*/\S*perl@#! /usr/bin/perl@' ./bin/cfgmaker ./bin/indexmaker ./bin/mrtg
/usr/bin/perl -0777 -p -i~ -e
's@GRAPHFMT="...";@GRAPHFMT="png";@' ./bin/mrtg ./bin/indexmaker
[root@mrtg mrtg-2.12.2]# make install
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/bin
mkdir /usr/local/mrtg-2
mkdir /usr/local/mrtg-2/bin
for x in ./bin/mrtg ./bin/cfgmaker ./bin/indexmaker; do \
          /usr/bin/install -c -m 755 $x /usr/local/mrtg-2/bin; done
for x in bin/rateup; do \
          /usr/bin/install -c -m 755 $x /usr/local/mrtg-2/bin; done
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/lib/mrtg2/Pod
mkdir /usr/local/mrtg-2/lib
mkdir /usr/local/mrtg-2/lib/mrtg2
mkdir /usr/local/mrtg-2/lib/mrtg2/Pod
for x in ./lib/mrtg2/*.pm; do \
          /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/lib/mrtg2; done
for x in ./lib/mrtg2/Pod/*.pm; do \
          /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/lib/mrtg2/Pod; done
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/share/mrtg2/icons
mkdir /usr/local/mrtg-2/share
mkdir /usr/local/mrtg-2/share/mrtg2
mkdir /usr/local/mrtg-2/share/mrtg2/icons
for x in ./images/*.gif ./images/*.png; do \
          /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/share/mrtg2/icons; done
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/share/doc/mrtg2
mkdir /usr/local/mrtg-2/share/doc
mkdir /usr/local/mrtg-2/share/doc/mrtg2
(cd .; for x in COPYING COPYRIGHT README CHANGES THANKS doc/*.pod doc/*.html doc/*.wml doc/*.txt doc/*.png; do \
          /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/share/doc/mrtg2; done)
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/man/man1
mkdir /usr/local/mrtg-2/man
mkdir /usr/local/mrtg-2/man/man1
for x in ./doc/*.1; do \
          /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/man/man1; done

[root@mrtg mrtg-2.12.2]#


MRTG 설치가 완료 되었으며, MRTG나 RRDTOOL을 사용하기 위해서 PATH를 지정하여 편리하게 사용하기로 한다.
[root@mrtg mrtg-2.12.2]# vi ~root/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/rrdbuild/lb/bin:/usr/local/rrdbuild/lib/include:/usr/local/mrtg-2/bin/:/usr/local/rrdtool-1.2.12/bin

export PATH
unset USERNAME



위에 굵게 표시 된 부분을 추가한다.

[root@mrtg mrtg-2.12.2]# source ~root/.bash_profile
[root@mrtg mrtg-2.12.2]#

변경된 PATH를 불러와 설정을 적용 시킨다. 이 설정 이후부터는 서버를 재부팅 하더라도 PATH가 적용된다.

[root@mrtg mrtg-2.12.2]# mrtg
-----------------------------------------------------------------------
ERROR: Mrtg will most likely not work properly when the environment
       variable LANG is set to UTF-8. Please run mrtg in an environment
       where this is not the case. Try the following command to start:

       env LANG=C /usr/local/mrtg-2/bin/mrtg 
-----------------------------------------------------------------------

[root@mrtg mrtg-2.12.2]#

MRTG가 제대로 적용 되었는지 확인하기 위해서 mrtg를 실행시켰다.
mrtg가 실행은 되었지만, 언어 설정이 맞지 않아 동작을 하지 않으므로 이에 맞게 설정을 변경 해주어야 한다.
X윈도에서 한글로 사용하는 것이 편리하다는 생각으로 한글로 설치도 해보고, 영문으로 설치도 해보았는데 근본적으로 위에 맡게 언어를 설정해주면 이 문제가 해결 되었다.

[root@mrtg mrtg-2.12.2]# vi /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"


아래와 같이 변경하고 저장한다.

LANG="C"
SYSFONT="latarcyrheb-sun16"



[root@mrtg mrtg-2.12.2]# reboot

Broadcast message from root (pts/1) (Thu Mar 25 11:52:28 2010):

The system is going down for reboot NOW!
[root@mrtg mrtg-2.12.2]#

재부팅을 하여도 설정사항이 제대로 적용 되었는지 확인하기 위해서 재부팅을 하였다.



서버가 부팅 된 후 MRTG가 제대로 동작하는지 확인 해 본다.

[root@mrtg ~]# mrtg
Usage: mrtg <config-file>

mrtg-2.12.2 is the Multi Router Traffic Grapher.

If you want to know more about this tool, you might want
to read the docs. They came together with mrtg!

Home: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/

[root@mrtg ~]#

MRTG가 제대로 작동하며, 이로써 MRTG 설치가 완료 되었다.
MRTG를 사용 하기 위해서 cfg 파일과 rrd 파일 그리고 log를 저장 할 곳이 필요 할 것이다.
내가 설치 한 서버에서는 mrtg를 관리 할 사용자를 생성하였으며, 그 디렉토리 안에 cfg, data, log 라는 이름으로 각 저장 할 디렉토리를 추가로 생성 해 주었다.

[root@mrtg ~]# adduser mrtg
[root@mrtg ~]# cd /home/mrtg/
[root@mrtg mrtg]# mkdir cfg
[root@mrtg mrtg]# mkdir data
[root@mrtg mrtg]# mkdir log




STEP 8.

웹에서 mrtg를 세팅 한 후 볼 수 있게 Apache를 설치한다.

[root@mrtg mrtg-2.12.2]# cd /usr/local/rrdbuild
[root@mrtg rrdbuild]# lftpget http://mirror.apache-kr.org/httpd/httpd-2.2.15.tar.gz
[root@mrtg rrdbuild]# tar xvfz httpd-2.2.15.tar.gz
..................... 생략 ...................
httpd-2.2.15/server/mpm_common.c
httpd-2.2.15/server/.indent.pro
httpd-2.2.15/server/util_charset.c
httpd-2.2.15/server/eoc_bucket.c
httpd-2.2.15/BuildAll.dsp
httpd-2.2.15/acinclude.m4
httpd-2.2.15/Makefile.win
httpd-2.2.15/httpd.spec
httpd-2.2.15/configure
httpd-2.2.15/configure.in
httpd-2.2.15/VERSIONING
httpd-2.2.15/README
httpd-2.2.15/LAYOUT
httpd-2.2.15/buildconf
httpd-2.2.15/.gdbinit
[root@mrtg rrdbuild]# cd httpd-2.2.15
[root@mrtg httpd-2.2.15]# ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so --enable-rewrite
...................... 생략 ........................
config.status: creating docs/conf/extra/httpd-mpm.conf
config.status: creating docs/conf/extra/httpd-multilang-errordoc.conf
config.status: creating docs/conf/extra/httpd-ssl.conf
config.status: creating docs/conf/extra/httpd-userdir.conf
config.status: creating docs/conf/extra/httpd-vhosts.conf
config.status: creating include/ap_config_layout.h
config.status: creating support/apxs
config.status: creating support/apachectl
config.status: creating support/dbmmanage
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands

[root@mrtg httpd-2.2.15]#

--prefix=/usr/local/apache는 /usr/local/apache에 설치한다.

--enable-mods-shared=all은 DSO모드라고 한다는데, 모듈이 추가로 설치 되었을 때 다시 컴파일 하지 않고 추가 할 수 있어서 좋다고 한다.

--enable-so는 DSO모드를 활성화 한다고 한다.

--enable-rewrite는 URL 재작성 모듈을 활성화 한다.


[root@mrtg httpd-2.2.15]# make
......................... 생략 ...............................
/usr/local/rrdbuild/httpd-2.2.15/srclib/apr/libtool --silent --mode=compile gcc -pthread  -O3  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE  -I/usr/local/rrdbuild/lb/include -I/usr/local/rrdbuild/lb/include/libart-2.0 -I/usr/local/rrdbuild/lb/include/freetype2 -I/usr/local/rrdbuild/lb/include/libpng  -I/usr/local/rrdbuild/httpd-2.2.15/srclib/pcre -I. -I/usr/local/rrdbuild/httpd-2.2.15/os/unix -I/usr/local/rrdbuild/httpd-2.2.15/server/mpm/prefork -I/usr/local/rrdbuild/httpd-2.2.15/modules/http -I/usr/local/rrdbuild/httpd-2.2.15/modules/filters -I/usr/local/rrdbuild/httpd-2.2.15/modules/proxy -I/usr/local/rrdbuild/httpd-2.2.15/include -I/usr/local/rrdbuild/httpd-2.2.15/modules/generators -I/usr/local/rrdbuild/httpd-2.2.15/modules/mappers -I/usr/local/rrdbuild/httpd-2.2.15/modules/database -I/usr/local/rrdbuild/httpd-2.2.15/srclib/apr/include -I/usr/local/rrdbuild/httpd-2.2.15/srclib/apr-util/include -I/usr/local/rrdbuild/httpd-2.2.15/server -I/usr/local/rrdbuild/httpd-2.2.15/modules/proxy/../generators -I/usr/local/rrdbuild/httpd-2.2.15/modules/ssl -I/usr/local/rrdbuild/httpd-2.2.15/modules/dav/main -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
/usr/local/rrdbuild/httpd-2.2.15/srclib/apr/libtool --silent --mode=link gcc -pthread  -O3    -L/usr/local/rrdbuild/lb/lib    -o mod_rewrite.la -rpath /usr/local/apache/modules -module -avoid-version  mod_rewrite.lo
make[4]: Leaving directory `/usr/local/rrdbuild/httpd-2.2.15/modules/mappers'
make[3]: Leaving directory `/usr/local/rrdbuild/httpd-2.2.15/modules/mappers'
make[2]: Leaving directory `/usr/local/rrdbuild/httpd-2.2.15/modules'
make[2]: Entering directory `/usr/local/rrdbuild/httpd-2.2.15/support'
make[2]: Leaving directory `/usr/local/rrdbuild/httpd-2.2.15/support'

make[1]: Leaving directory `/usr/local/rrdbuild/httpd-2.2.15'
[root@mrtg httpd-2.2.15]# make install
................... 생략 ...................
mkdir /usr/local/apache/htdocs
Installing error documents
mkdir /usr/local/apache/error
Installing icons
mkdir /usr/local/apache/icons
mkdir /usr/local/apache/logs
Installing CGIs
mkdir /usr/local/apache/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory `/usr/local/rrdbuild/httpd-2.2.15'

[root@mrtg httpd-2.2.15]#

Apache의 환경을 설정한다.

[root@mrtg httpd-2.2.15]# vi /usr/local/apache/conf/httpd.conf
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

</IfModule>
</IfModule>


위 부분을 아래와 같이 변경한다.

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch. 
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group nobody

</IfModule>
</IfModule>



# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName
www.example.com:80

위 부분을 아래와 같이 주석을 제거해 준다. 그리고 IP에 맞게 웹서버를 등록 해 준다.

필자의 경우에는 DNS 서버를 올리지 않았기 때문에 IP를 입력 하였다.

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#

ServerName 192.168.100.2:80

이제 Apache 설치는 완료 되었으며 Apache를 실행하면 된다.

[root@mrtg httpd-2.2.15]# /usr/local/apache/bin/apachectl start
[root@mrtg httpd-2.2.15]#


웹서버가 뜨는 것을 확인 할 수 있다.

위 스샷과 같이 안 나온다면, 리눅스 설치 시 방화벽에 http 포트를 열어주었는지 확인한다.



[root@mrtg httpd-2.2.15]# vi /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/local/apache/bin/apachectl start

위와 같이 리눅스가 부팅 될 때 웹서버가 자동으로 실행되게 저장한다.



Apache 설치가 완료 되었지만, MRTG는 cgi를 이용하여 웹서버에 표현을 해주기 때문에 cgi를 실행 할 수 있게 httpd.conf의 설정 부분을 변경해야 한다.

[root@mrtg httpd-2.2.15]# cd /usr/local/apache/conf/
[root@mrtg conf]# vi httpd.conf
# running httpd, as with most system services.
#
User daemon
Group daemon

</IfModule>
</IfModule>

# 'Main' server configuration

아래와 같이 변경 한다.

# running httpd, as with most system services.
#
User nobody
Group nobody

</IfModule>
</IfModule>

# 'Main' server configuration



# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being


역시 아래와 같이 추가한다.

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php index.cgi
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being



<Directory "/usr/local/apache/cgi-bin">
    AllowOverride None
    Options none
    Order allow,deny
    Allow from all
</Directory>


아래와 같이 변경한다.

<Directory "/usr/local/apache/cgi-bin">
    AllowOverride None
   
Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>



    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":


아래와 같이 추가한다.

    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    AddType application/x-httpd-cgi .cgi .pl

    #
    # AddHandler allows you to map certain file extensions to "handlers":




    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var


아래와 같이 추가한다.

    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    AddHandler cgi-script .cgi .pl

    # For type maps (negotiated resources):
    #AddHandler type-map var


이제 웹서버에서 cgi를 적용 할 수 있는 환경이 완료 되었다.
기본 cgi-bin 경로는 /usr/local/apache/cgi-bin 으로 설정 되어있다.




'Linux tools > MRTG' 카테고리의 다른 글

MRTG서버에 Weathermap 설치 및 사용하기  (0) 2010.03.26
MRTG 설정 및 사용하기  (0) 2010.03.25
블로그 이미지

쭈꾸댕이

아직 어설픈 실력으로 나름 제가 하는 것에 대한 것들을 옮기는 공간입니다. 틀린 부분도 있을 수 있으니 이 점 양해하시고, 도움이 되셨으면 좋겠네요.

,