인터넷을 검색한 결과 대부분 소스 컴파일 방식이라 자료 찾기가 어려웠다.
하지만 apt-get으로 설치해야 해서 여기 저기 찾아서 해보았다.

apt-get install mrtg rrdtool librrds-perl
하라고 되어있다.
이미 mrtg는 설치했으니, rrdtools과 librrds-perl을 설치한다.
apt-get install rrdtool librrds-perl

그리고 이미 snmp는 라우터의 것을 사용하니, 이것도 패스..
섶이 위치는 다음과 같다.
소스 컴파일시에서는 이런것을 설정해야하지만, apt을 이용하면 이런 귀찮음이 없어진다.
하지만 단점은 어디에 설치되었는지 찾기 어렵다는 것이다.
/usr/lib/perl
/usr/bin/rrdtool

mrtg.cfg 파일을 변경해야 한다.
 vi /etc/mrtg.cfg

### Global Defaults
Logformat: rrdtool
이것만 추가하면 된다.
소스 컴파일시에는 PathAdd, LibAdd를 추가해야하지만, apt-get으로 설치했을 경우는 상관없는듯하다.

html 위치는 /var/www/mrtg 로...

그후 MRTS을 다운 받아야 한다.
Logformat을 rrdtool로 변경하면 더이상 MRTG가 그래프를 그리지 못한다. 그래서 RRDTool을 이용해야 한다.
MRTS(MRTG RRDtool Total Statistics) : php 기반의 프로그램이다.
다운로드 사이트: http://download.tsdn.dk/software/mrts/
cd /var/www/mrtg
wget http://download.tsdn.dk/software/mrts/mrts-v0.1.1.php.gz
gunzip mrts-v0.1.1.php.gz
ln -s mrts-v0.1.1.php mrts.php

이후에 $dir 위치를 변경한다.
이곳은 MRTG+RRDTool 그래프가 그려질 디렉토리이다.
 vi /var/www/mrtg/mrts.php
 
/* The directory where the rrd files are located */
$dir = '/var/www/mrtg';
17번째 라인에서 mrtg 디렉토리로 변경한다.

참고로 26번째 라인에 RRDTool 바이너리 파일 지정이 있는데,
/* RRDtool path - where are the the executable located */
$rrdcommand = '/usr/bin/rrdtool';
이미 설정되어 있다.
소스 컴파일에서는 다 해줘야하지만, apt-get에서는 필요가 없다. 이것 좋은 점..

아파치를 재시작..
 /etc/init.d/apache2 restart

이제 웹페이지 확인하면 된다.
처음엔 타이틀만 보이지만 5분뒤에 모든 그래픽이 보인다.
http://localhost/mrtg/mrts.php

윈도우에서 하려고 하다가 못했는데,
리눅스에서 하니 기분은 좋다..^^


참고 자료:

Home of MRTS - MRTG RRDtool Total Statistics.

Download it or see what it does

How to use it

For a more complete installation guide see this tutorial by Bjoern Weiland

To use MRTS you need to install and set up MRTG and RRDtool.

If you are a Debian GNU/Linux user just do a
apt-get install mrtg rrdtool librrds-perl
if you use another OS, you can probably figure it out youself (or you could change to Debian).

It can also be a good idea to have some standard snmp tools installed (in Debian the package is "snmp"), and if you want to log network traffic on a machine, then install a snmp server (Debian: "snmpd").

Set up the snmp server to allow read access from the machine that is running MRTG (in our example the same machine that we are logging therefore we allow access to 127.0.0.1). If you are using Debian and have installed the snmpd package, you should change a line or two in "/etc/snmp/snmpd.conf". From:

com2sec paranoid   default         public
#com2sec readonly default public
#com2sec readwrite default private to:
#com2sec paranoid default public
com2sec readonly 127.0.0.1 public
#com2sec readwrite default private \and then restart the snmp server: /etc/init.d/snmpd restart

Now you have to find out what device you want to log. You can find this out with this command:

$ snmpwalk 127.0.0.1 public interfaces.ifTable.ifEntry.ifDescr
interfaces.ifTable.ifEntry.ifDescr.1 = lo
interfaces.ifTable.ifEntry.ifDescr.2 = eth0

in this example, we want to log traffic on the eth0, so the number we must use is 2.
Set up the mrtg config file (Debian: "/etc/mrtg.cfg") with something like this:
# Global configuration
WorkDir: /var/log/mrtg
WriteExpires: Yes
Logformat: rrdtool

#For every machine
Target[name-of-machine]: 2:public@127.0.0.1
MaxBytes[name-of-machine]: 12500000
Title[name-of-machine]:
PageTop[name-of-machine]:

In the "Target" line you see the number 2 we found before, and in "MaxBytes" we have set how many bytes the device maximum can transfer (100Mbit * 1000000bit/Mbit / 8byte/bit = 12500000byte).

Now all you have to do is put mrts.php in the web scope and browse into it. (maybe you have to change something in the top of mrts.php)

You can't run the script in "safe mode php", if you server does this as standard, you have to put something like this in your httpd.conf:

<Directory "/path/to/mrts">
php_admin_value safe_mode 0
</Directory>
Posted by 노을지기