MRTG Installation




SNMP Configuration
What is SNMP?
Most routers and firewalls keep their operational statistics in Management Information Blocks (MIBs). Each statistic has an Object Identifier (OID) and can be remotely retrieved from the MIB via the Simple Network Management Protocol (SNMP). However, as a security measure, you need to know the SNMP password or “community string” to do so. There are a
number of types of community strings, the most commonly used ones are the “Read Only” community string that only provides access for viewing statistics and system parameters. In many cases the “Read Only” community string or password is set to “public”. There is also a “Read Write” community string for not only viewing statistics and system parameters but also for updating the parameters too.

1) Check for NetSNMP server package

a) Look if there is a folder named /etc/snmp/

*)If such a folder does not exist, then

Download & Install the following RPMs


Find it in, websites.


yum install net-snmp*

2) Configuration of snmpd.conf
a) Inside the /etc/snmp/ folder, there will be the snmp configuration
file named, snmpd.conf
b) mv snmpd.conf snmpd.conf.old
c) vi snmpd.conf
Enter the following line in the new configuration file to set the Read
Only community string to any password of your choice, say for eg.,

rocommunity 1q2w3e

d) /etc/rc.d/init.d/snmpd start
Run the following commnds from the command line

a) snmpwalk -v 1 -c 1q2w3e localhost system
b) snmpwalk -v 1 -c 1q2w3e localhost interface

The above steps are called as polling localhost. You can poll any SNMP
aware network device that has SNMP enabled. All you need is the IP
address and SNMP read only string and you’ll be able to get similar

There are currently three versions of SNMP; versions 1, 2 and 3. The
Linux snmpwalk and snmpget commands have v 1, v 2c and v 3 switches for
specifying the SNMP version to be used for queries. Always make sure you
are using the correct one.

Now that we know SNMP is working correctly on your Linux server, we can
configure a SNMP statistics gathering software package such as MRTG to
create online graphs of your traffic flows.


Check for zlib
Through, phpinfo(), check if zlib is installed.

If not, then


gunzip -c zlib-*.tar.gz | tar xf –
rm zlib-*.tar.gz
mv zlib-* zlib
cd zlib

Check for libpng

rpm -qa | grep -w libpng

If not available, install it.

Check for gd
Similarly, check for gd library, through phpinfo() and if not available
install it.


1) MRTG Installation

a) tar xzvf mrtg-2.10.13.tar.gz

2) MRTG Compilation

a) cd mrtg-2.10.13
b) ./configure –prefix=/usr/local/mrtg-2
c) make
d) make install

3) MRTG Configuartion: Creating a MRTG configuration file for manipulating MRTG

a) cd /usr/local/mrtg-2/bin
b) mkdir /home/mrtg
c) ./cfgmaker –global ‘WorkDir: /home/mrtg’ –global ‘Options[_]:bits,growright’ –output=mrtg.cfg 1q2w3e@localhost

The above line means that,

The MRTG configuration file, mtrtg.cfg, is created in the path /usr/local/mrtg-2/bin/mrtg.cfg

The MRTG traffic graphs and webpages when generated will be stored under the folder /home/mrtg/. Workdir specifies where the logfiles and the webpages should be created.

d) ./indexmaker –output=/home/mrtg/index.html mrtg.cfg

The above line means that, in order to view the MRTG graphs through browser, an index file will be created under the MRTG home path(specified by .cfgmaker in step c), /home/mrtg/index.html

e) cd /usr/local/apache/conf/
vi httpd.conf

Add the following line

Alias /mrtg/ /home/mrtg/

Restart apache service

service httpd stop
service httpd start

f) Set a cron job to generate mrtg traffic graphs and webpages, every
5 minutes

vi /var/spool/cron/root
*/5 * * * * env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/bin/mrtg.cfg –logging /var/log/mrtg.log >/dev/null 2>&1

g) service crond restart

then, restart snmpd daemon,

/etc/init.d/snmpd restart

h) view http://serverip/mrtg/

Inorder to set 64-bit MRTG counter. we need to add highlighted thing in
the mrtg.cfg configuration file

Then restart the following services.

Find the following values and change them as like given below.

Target[localhost_1]: 1:1q2w3e@localhost:::::2
Target[localhost_2]: 2:1q2w3e@localhost:::::2
Target[localhost_3]: 3:1q2w3e@localhost:::::2

If you feel this is tricky and you can’t take any risk, our Web Hosting experts can assist you in getting this fixed at a pocket-friendly price. All you need to do is to contact us and we’ll take care of the rest.