Computer/LINUX

mrtg2

알찬돌삐 2012. 8. 10. 16:16

MRTG설치


MRTG가 뭔가?
자세한건 해당 사이트에 가서 보고(www.mrtg.org), 여기서는 설치법만을 설명한다.
설치하고 보면, 감이 올것이라 믿는다. mrtg에 대해서 이미 많은 문서가 있으므로
여기서는 내가 작업한 것에 대한 정리라는 생각으로 적어나가려 한다.

MRTG를 설치하려면 다음과 같은 놈들이 있어야 한다.

gcc  (이거 깔리지 않은 곳은 없겠지?)
perl (이거 깔리지 않은 곳은 없겠지?)
gd (www.boutell.com)
libpng (www.libpng.org)
zlib (www.info-zip.org/pub/infozip/zlib/)

나의 경우, libpng, zlib는 rpm으로 설치되어 있었다.
따라서 gd만 설치해주면 되었다.

현재 gd버전은 1.8.4이다.
홈페이지에 가보니 2.0버전대가 베타개발상태인가 보다.
본인이 원래 최신버전 집착증이 좀 있긴한데 그냥 1.8.4를 아무 이유없이
쓰기로 결정했다. 받아오자.
현재 집에서 ADSL로 하기땜에 사무실에 있는 리눅스서버에서 바로 받기로 하자.

GD 설치
[root@ns /down]# wget ftp://ftp.boutell.com/pub/boutell/gd/gd-1.8.4.tar.gz
--18:46:14--  ftp://ftp.boutell.com:21/pub/boutell/gd/gd-1.8.4.tar.gz
           => `gd-1.8.4.tar.gz'
Connecting to ftp.boutell.com:21... connected!
Logging in as anonymous ... Logged in!
==> TYPE I ... done.  ==> CWD pub/boutell/gd ... done.
==> PORT ... done.    ==> RETR gd-1.8.4.tar.gz ... done.
Length: 257,631 (unauthoritative)

    0K -> .......... .......... .......... .......... .......... [ 19%]
   50K -> .......... .......... .......... .......... .......... [ 39%]
  100K -> .......... .......... .......... .......... .......... [ 59%]
  150K -> .......... .......... .......... .......... .......... [ 79%]
  200K -> .......... .......... .......... .......... .......... [ 99%]
  250K -> .                                                      [100%]

18:46:25 (28.49 KB/s) - `gd-1.8.4.tar.gz' saved [257631]

[root@ns /down]# tar xvzf gd-1.8.4.tar.gz -C /usr/local/src
생략..

[root@ns /down]# cd /usr/local/src/gd-1.8.4/
[root@ns gd-1.8.4]# make
gcc -I. -I/usr/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include  -O 
-DHAVE_LIBPNG -DHAVE_LIBJPEG   -c gd.c -o gd.o
이하 생략

[root@ns gd-1.8.4]# make install
sh ./install-item 644 libgd.a /usr/local/lib/libgd.a
sh ./install-item 755 pngtogd /usr/local/bin/pngtogd
sh ./install-item 755 pngtogd2 /usr/local/bin/pngtogd2
sh ./install-item 755 gdtopng /usr/local/bin/gdtopng
sh ./install-item 755 gd2topng /usr/local/bin/gd2topng
sh ./install-item 755 gd2copypal /usr/local/bin/gd2copypal
sh ./install-item 755 gdparttopng /usr/local/bin/gdparttopng
sh ./install-item 755 webpng /usr/local/bin/webpng
sh ./install-item 755 bdftogd /usr/local/bin/bdftogd
sh ./install-item 644 gd.h /usr/local/include/gd.h
sh ./install-item 644 gdcache.h /usr/local/include/gdcache.h
sh ./install-item 644 gd_io.h /usr/local/include/gd_io.h
sh ./install-item 644 gdfontg.h /usr/local/include/gdfontg.h
sh ./install-item 644 gdfontl.h /usr/local/include/gdfontl.h
sh ./install-item 644 gdfontmb.h /usr/local/include/gdfontmb.h
sh ./install-item 644 gdfonts.h /usr/local/include/gdfonts.h
sh ./install-item 644 gdfontt.h /usr/local/include/gdfontt.h



MRTG(Multi Routing Traffic Grapher)설치
[root@ns gd-1.8.4]# cd ..
[root@ns src]# cd mrtg-2.9.10/
[root@ns mrtg-2.9.10]# ./configure --prefix=/usr/local/mrtg
loading cache ./config.cache
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking whether make sets ${MAKE}... yes
checking for a BSD compatible install... /usr/bin/install -c
checking for perl... /usr/bin/perl
checking for groff... /usr/bin/groff
checking for sqrt in -lm... yes
checking for acos in -lm... yes
checking for gdImageGif in -lgd... no
checking for gdImagePng in -lgd... yes
checking for gd.h... yes
checking the weather... (cached) its fine
updating cache ./config.cache
creating ./config.status
creating Makefile
ordering CD from http://ee-staff.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 
----------------------------------------------------------------


음.. 마지막에 농담을 하는것이 특이하군..
계속해서 시킨대로 make과 make istall를 하자

[root@ns mrtg-2.9.10]# make 
생략..
[root@ns mrtg-2.9.10]# make install
생략..


자, /usr/local/mrtg에 설치가 되었을 것이다.
[root@ns mrtg-2.9.10]# cd /usr/local
[root@ns local]# l
total 17
drwxr-xr-x   12 root     root         1024 Mar 21 18:18 apache/
drwxr-xr-x    2 root     root         1024 Apr  5 18:41 bin/
drwxr-xr-x    7 root     root         1024 Mar 22 14:10 dns/
drwxr-xr-x    2 root     root         1024 Feb  7  1996 doc/
drwxr-xr-x    2 root     root         1024 Feb  7  1996 etc/
drwxr-xr-x    2 root     root         1024 Feb  7  1996 games/
drwxr-xr-x    3 root     root         1024 Apr  5 18:41 include/
drwxr-xr-x    2 root     root         1024 Feb  7  1996 info/
drwxr-xr-x    3 root     root         1024 Apr  5 18:41 lib/
drwxr-xr-x   12 root     root         1024 Mar 25 04:22 man/
drwxr-xr-x    6 root     root         1024 Apr  5 18:52 mrtg/
drwxr-xr-x    7 root     root         1024 Mar 20 11:57 openssh/
drwxr-xr-x    7 root     root         1024 Mar 20 11:47 openssl/
drwxr-xr-x    2 root     root         1024 Mar 21 14:30 sbin/
drwxr-xr-x    4 root     root         1024 Mar 21 18:55 share/
drwxr-xr-x   10 root     root         1024 Apr  5 18:35 src/
drwxr-xr-x    6 root     root         1024 Mar 19 01:43 ssl/
[root@ns local]# 


환경을 설정해야지..
환경설정툴로 cfgmaker라는 놈을 제공한다.
이전에 webhosting/mrtg라는 디렉토리를 만들고, 아파치의 Virtual Host에 mrtg.inkistar.tv(각자에 맞게 설정)
라는 주소를 추가해 준다. inkistar.tv부분은 자신의 도메인에 해당하는 것으로 한다.
dns에도 mrtg호스트를 추가해 준다.

[root@ns mrtg]# tail /var/named/zone-inkistar.tv 
        IN      A               211.43.134.240

        IN      MX      10      mail

mail    IN      CNAME           @
ns      IN      CNAME           @
www     IN      CNAME           @
ftp     IN      CNAME           @
mrtg    IN      CNAME           @

[root@ns lib]# cd /usr/local/mrtg
[root@ns lib]# mkdir cfg
[root@ns lib]# cd bin
[root@ns bin]# ./cfgmaker \
> --global 'WorkDir: /webhosting/mrtg/' \
> --global 'Language: korean' \
> --global 'Options[_]: bits,growright' \
> --output /usr/local/mrtg/cfg/mrtg.cfg \
> community@211.43.xxx.xxx (자신의 gateway or router의 주소를 입력)
--base: Get Device Info on community@211.43.xxx.xxx:
--base: Vendor Id: 
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifSpeed
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Writing /usr/local/mrtg/cfg/mrtg.cfg
[root@ns bin]# cd ../cfg
[root@ns cfg]# l
total 4
-rw-r--r--    1 root     root         3398 Apr  5 19:33 mrtg.cfg


만들어진 mrtg.cfg가 설정파일이다.
이제 한번 돌려본다.
처음 2회까지는 warning을 뱉으면서 뭐라고 하지만, 그 이후론 문제없이 된다.
원래 그런거니까 신경쓸 필요 없다.

[root@ns cfg]# ../bin/mrtg mrtg.cfg
이하생략..

그럼 위에서 지정한 /webhosting/mrtg에 로그파일들이 생성된다.
이제 아파치를 실행하고 그냥 웹브라우저에서 보면 된다.
하지만, 아래의 주소는 막아두었으니 들어가려 하지 말자..

http://mrtg.inkistar.tv

하지만 index.html파일을 만들지 않기 때문에 파일이름도 같이 지정해야 한다.
[root@ns cfg]# cd ../bin
[root@ns bin]# ./indexmaker -t 'Router' -r . -o /webhosting/mrtg/index.html ../cfg/mrtg.cfg
Use of uninitialized value at ./indexmaker line 174.
--base: Writing /webhosting/mrtg/index.html


이제 /webhosting/mrtg/index.html파일에 생기고 여러개의 페이지를 편하게 볼수 있다.
mrtg는 5분마다 실행하는 것이 관례라 이를 crontab에 등록하자.

쩝.. 마지막과정이니 기뻐하시라
crontab에 등록된 내용이다. 만드는 것은 crontab -e를 사용하라.

[root@ns bin]# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.10180 installed on Thu Apr  5 20:51:23 2001)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
*/5 * * * * /usr/local/mrtg/bin/mrtg /usr/local/mrtg/cfg/mrtg.cfg 

그럼 5분주기로 cron이 실행해 줄 것이다.

지장은 없으나, 마지막으로 그림파일을 복사한다. 아니면 그림들이 깨져 나온다.
cp /usr/local/mrtg/lib/mrtg2/*.png /webhosting/mrtg/
끝.

[추가사항]
정리:
/usr/local/mrtg/bin/cfgmaker \
--global 'WorkDir: /webhosting/mrtg/' \
--global 'Language: korean' \
--global 'Options[_]: bits,growright' \
--output /webhosting/mrtg/mrtg.cfg \
public@dbakorea.pe.kr

/usr/local/mrtg/bin/mrtg mrtg.cfg

/usr/local/mrtg/bin/indexmaker -t 'DBAKOREA' -r . -o /webhosting/mrtg/index.html /webhosting/mrtg/mrtg.cfg

cp /usr/local/mrtg/lib/mrtg2/*.png .

[출처] MRTG 설치 운영|작성자 마검린

이 글은 스프링노트에서 작성되었습니다.

.

'Computer > LINUX' 카테고리의 다른 글

qmail vpopmail mysql 설치  (0) 2012.08.10
Qmail Antispam 구축  (0) 2012.08.10
mrtg  (0) 2012.08.10
커널 파라메터  (0) 2012.08.10
expect  (1) 2012.08.10