MRTG란 Multi Router Traffic Grapher 한다. (왜? 정의하니깐..ㅡㅡ;;)

그래서 그냥 설치하기로..^^
문제는 mrtg는 기본이 root로 설정하고자 해서...
이번만 sudo를 사용하지 않고, 그냥 root 계정으로 설치한다.

 su -i
라고 하면 현재 계정의 비밀번호를 물어본다.
입력하면 자주 보았던 # <- root 계정 접속.(비추천..^^)

내 설정은 현 리눅스가 아닌, 라우터의 정보를 받을 예정임.
귀차니즘으로 인하여 둘 다 설치.. 하지만 snmpd는 설정하지 않을 예정..
 apt-get install mrtg snmpd
창이 나오면서 root만 사용할 것이냐고 물어봄.

기본 웹 디렉토리를 /var/www/mrtg
설정 파일은 /etc/mrtg.cfg
 mkdir /var/www/mrtg

설정파일에 추가
 vi /etc/mrtg.cfg

# Global Settings
RunAsDaemon: yes
EnableIPv6: no
WorkDir: /var/www/mrtg
Options[_]: bits,growright
WriteExpires: Yes

cron 파일 점검
 cat /etc/cron.d/mrtg
0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

cfg 파일 생성
 cfgmaker MRTG@ > /etc/mrtg.cfg
이곳이 중요하다.
이미 ns-5gt에 snmp 설정을 하였다.
MRTG 이름으로 하였고, 사설 아이피인 기본 아이피로 사용중이다.
그리고 이 장비에서 서버 아이피로 snmp로 전송되게 설정이 끝난 상태이다.

아무런 메시지가 안 나오면 이상이 없는 것이다.
snmp 등 에러메시지가 나오면 점검해야한다.

HTML 파일을 생성한다.
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
역시 아무런 메시지가 없으면 끝..

그후 웹페이지로 확인한다.

corn에 등록
 vi /var//var/spool/cron/crontabs/root

*/5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null
5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null
5분 마다 실행하는 것이다.
이것은 mrtg가 root만 접속하기 때문에 이곳에 설정..
[While 님의 도음으로 수정합니다.]

나중에 cpu 및 ram도 테스트해야겠음..

What is MRTG?

The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network links. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic.

Download MRTG

MRTG Documentation

First you need to install apache2 webserver for this click here

Now we need to install mrtg and snmp

Installing MRTG in Debian

#apt-get install mrtg snmpd

The installation will create an mrtg subdirectory where the Apache Web pages reside. On your Debian system the path of this subdirectory is:


Now you need to edit the mrtg configuration file to edit the some of the settings

File is located at /etc/mrtg.cfg you need to change the global settings as follows

# Global Settings

RunAsDaemon: yes
EnableIPv6: no
WorkDir: /var/www/mrtg
Options[_]: bits,growright
WriteExpires: Yes

Title[^]: Traffic Analysis for

You will find a crontab running every 5 minutes as user root

# cat /etc/cron.d/mrtg
0-55/5 * * * * root if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then env LANG=C /usr/bin/mrtg /etc/mrtg.cfg >> /var/log/mrtg/mrtg.log 2>&1; fi

Now we need to assign the snmp community name in snmp configration file /etc/snmp/snmpd.conf

# source community
# com2sec paranoid default public
com2sec readonly default public
#com2sec readwrite default private

Now you need to restart the snmp service

#/etc/init.d/snmpd restrat

The configuration file creating using

#cfgmaker public@localhost > /etc/mrtg.cfg

Creating a configuration file for a device using

#cfgmaker public@ >> /etc/mrtg.cfg

With the configuration file created correctly there's only one other thing you have to do and that's to use the indexmaker utility to create the summary home page. Since you have to re-run this command every time you make certain changes to the /etc/mrtg.cfg configuration file,

Creating index file for the webserver using

#indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

Now you need to reboot your system wait for five minutes or so and then take a look at your summary home page. If your Debian system's IP address is then you'd type in the following in the address bar of a browser running on a system on the same network:

Your summary home page should come up with a graph for each target entry in the configuration file. If a graph looks like there's no data on it, click on it and check the statistics to see if any traffic is being seen. Small amounts of traffic won't show up on the graphs because we used the Unscaled statement

Some of examples how to monitor cpu and memory usage

CPU Usage


WorkDir: /var/www/localhost/htdocs/mrtg
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@ ssCpuRawSystem.0&ssCpuRawSystem.0:public@
RouterUptime[localhost.cpu]: public@
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: CPU Load
PageTop[localhost.cpu]: <H1>Active CPU Load %</H1>
Unscaled[localhost.cpu]: ymwd
ShortLegend[localhost.cpu]: %
YLegend[localhost.cpu]: CPU Utilization
Legend1[localhost.cpu]: Active CPU in % (Load)
LegendI[localhost.cpu]: Active
Options[localhost.cpu]: growright,nopercent

Memory Usage


LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
Target[localhost.mem]: .
PageTop[localhost.mem]: <H1>Free Memory</H1>
WorkDir: /var/www/localhost/htdocs/mrtg
Options[localhost.mem]: nopercent,growright,gauge,noinfo
Title[localhost.mem]: Free Memory
MaxBytes[localhost.mem]: 1000000
kMG[localhost.mem]: k,M,G,T,P,X
YLegend[localhost.mem]: bytes
ShortLegend[localhost.mem]: bytes
LegendI[localhost.mem]: Free Memory:
Legend1[localhost.mem]: Free memory, not including swap, in bytes

Creating jobs for the above two examples



/usr/bin/mrtg /etc/mrtg/cpu.cfg



/usr/bin/mrtg /etc/mrtg/mem.cfg

Run each script 3 times (disregard the warnings)


Make the Index Files

#/usr/bin/indexmaker --output=/var/www/mrtg/index.html \
--title="Memory and CPU Usage :)" \
--sort=name \
--enumerate \
/etc/mrtg/cpu.cfg \

Make the mrtg.cfg file

#cfgmaker --global "WorkDir: /var/www/mrtg/" \
--global "Options[_]: growright,bits" \
--ifref=ip \
public@localhost > /etc/mrtg/mrtg.conf

Cronjob setup

/bin/cat >> /var/spool/cron/crontabs/root
*/5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null

Posted by 노을지기

댓글을 달아 주세요

  1. 2011.09.03 22:20

    5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null
    이것은 매 시간 5분에 시작하는 것으로 1시간에 한번입니다.

    */5 * * * * /bin/run-parts /etc/cron.mrtg 1> /dev/null
    이렇게 수정해주셔야합니다.

  2. 2011.09.09 06:32 신고

    아 감사합니다.

  3. 2013.01.05 19:05

    Les agriculteurs ont peut-être trouvé un nouveau créneau d'activité pendant l'hiver : déneiger les routes en échange d'une rémunération, moncler chaquetas, comme l'a proposé la chambre d'agriculture d'Ile-de-France aux pouvoirs publics de cette région handicapée par la neige en décembre. Selon la Chambre d'Agriculture interdépartementale d'Ile de France, moncler online, qui a consacré des efforts au sujet,, l'exemple a été donné par l'Eure-et-Loir, moncler españa, où un accord a été conclu par le Conseil général avec les agriculteurs locaux, moncler, dont les tracteurs ont été équipés pour le déneigement. Economie Composants: Qualcomm achète Atheros pour 3, moncler outlet,1 milliards de dollars Economie 35h: le Medef opposé à une suppression des allégements de chargesRelated articles: