A blog for Linux Lovers.

Posted by sibu on March 3, 2009


MRTG (Multi Router Traffic Grapher) is an application that allows us to observe the traffic of a network.

Before Mrtg installation we have to install SNMP on the server.

#yum install net-snmp-utils net-snmp

And we start the server.

# chkconfig –level 345 snmpd

We can see that it is running in port 199.
# service snmpd start

# netstat -natv | grep ‘:199′

tcp 0 0* LISTEN


We run ‘snmpwalk’ which creates a “tree” of information for our network. If you see an output like this one you may proceed with the MRTG installation. Else you should make some configuration first.
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex. = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex. = 2

We keep a backup of snmpd.conf just in case anything goes wrong
# cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original

# nano /etc/snmp/snmpd.conf

And do the follow changes:

* Replace following line

com2sec notConfigUser default public

with those

com2sec local localhost public
com2sec mynetwork public

(where we put what our network is)

* Replace following line

group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser

with those

group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
group MyROGroup usm mynetwork

* find and replace following lines

view systemview included .
view systemview included .

with this

view all included .1 80

* find and replace following line

access notConfigGroup “” any noauth exact systemview none none

with those

access MyROGroup “” any noauth exact all none none
access MyRWGroup “” any noauth exact all all none

* and finally replace those lines

syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)

with something like this

syslocation Linux, Fedora Core 6
syscontact Root root@localhost

We restart the server to take affect of the notices

# service snmpd restart

And we run again

# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

Now we should see something like that

IP-MIB::ipAdEntIfIndex. = INTEGER: 2
IP-MIB::ipAdEntIfIndex. = INTEGER: 1

(Where is your ip address. )

MRTG Installation

# yum install mrtg
# mkdir /var/www/html/mrtg/

( in which our graphs and html pages will be kept)

And next run ‘cfgmaker’ for the configuration file to be created.

# cfgmaker –global “workdir: /var/www/mrtg” -ifref=ip –output /etc/mrtg/mrtg.cfg –global ‘options[_]: growright,bits’ public@localhost

With this command we tell MRTG to create a configuration file with the name ‘mrtg.cfg’ for the traffic of our computer (localhost). Instead of localhost you may put the address of any computer you may monitor as long as it runs SNMP.

Next we create our default index page

# indexmaker –output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg

Apache configuration

MRTG creates a file ‘mrtg.cfg’ under /etc/httpd/conf.d we contains all the necessary for Apache. We change it to contain the ips we want to have access to our MRTG graphs.

Alias /mrtg /var/www/mrtg

<Location /mrtg>
Order deny,allow
Deny from all
Allow from

We run the following command

In case you get an error like this
# mrtg /etc/mrtg/mrtg.cfg

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/bin/mrtg /etc/mrtg/mrtg.cfg

you have to run the above command more than once till it runs without any error. This is normal.
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

23-02-2007 17:28:53, Rateup WARNING: /usr/bin/rateup Can’t remove localhost_2.old updating log file

# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg


Now you can access mrtg at

Add A Comment