Install and Configure MRTG on Ubuntu 16.10 Server

Sponsored Link
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.

MRTG Features


MRTG works on most UNIX platforms and Windows NT.


MRTG is written in Perl and comes with full source.

Portable SNMP

MRTG Uses a highly portable SNMP implementation written entirely in Perl (thanks to Simon Leinen). There is no need to install any external SNMP package.

SNMPv2c support

MRTG can read the new SNMPv2c 64bit counters. No more counter wrapping.

Reliable Interface Identification

Router interfaces can be identified by IP address, description and ethernet address in addition to the normal interface number.

Constant size Logfiles

MRTG's logfiles do NOT grow thanks to the use of a unique data consolidation algorithm.

Automatic Configuration

MRTG comes with a set of configuration tools which make configuration and setup very simple.


Time critical routines are written in C .

GIF free Graphics

Graphics are generated directly in PNG format using the GD library by Thomas Boutell.


The look of the webpages produced by MRTG is highly configurable.


MRTG has built-in hooks for using RRDtool. If you are strapped for performance this may help.


You need to make sure you have apache2,snmp packages are installed before starting MRTG installation

sudo apt-get install apache2 snmpd snmp

Now you need to edit the /etc/snmp/snmpd.conf file

sudo vi /etc/snmp/snmpd.conf

uncomment the following line

#rocommunity public localhost


rocommunity public localhost

Save and exit the file

You need to restart the snmpd service using the following command

sudo systemctl snmpd restart

Install MRTG Using the following command

sudo apt-get install mrtg

MRTG Configuration

You need to create mrtg directory under /var/www/html

sudo mkdir /var/www/html/mrtg

Backup the original /etc/mrt.cfg file:

sudo cp /etc/mrtg.cfg /etc/mrtg.cfg.ORIGINAL

Now you need to edit the /etc/mrt.cfg file

vi sudo /etc/mrt.cfg

change the working directory from

WorkDir: /var/www/mrtg


WorkDir: /var/www/html/mrtg

Save and exit the file

Create a configuration file for MRTG:

cfgmaker @ > /etc/mrtg.cfg

In this case we are using local server we are trying to monitor and output looks similar to the following

# cfgmaker [email protected] > /etc/mrtg.cfg

--base: Get Device Info on [email protected]:
--base: Vendor Id: Unknown Vendor --
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd: [email protected]: -> 1 -> ifIndex = 1
--snpd: [email protected]: -> 2 -> ifIndex = 2
--snpd: [email protected]: -> 3 -> ifIndex = 3
--base: Walking ifType
--snpd: [email protected]: -> 1 -> ifType = 24
--snpd: [email protected]: -> 2 -> ifType = 6
--snpd: [email protected]: -> 3 -> ifType = 6
--base: Walking ifAdminStatus
--snpd: [email protected]: -> 1 -> ifAdminStatus = 1
--snpd: [email protected]: -> 2 -> ifAdminStatus = 1
--snpd: [email protected]: -> 3 -> ifAdminStatus = 1
--base: Walking ifOperStatus
--snpd: [email protected]: -> 1 -> ifOperStatus = 1
--snpd: [email protected]: -> 2 -> ifOperStatus = 1
--snpd: [email protected]: -> 3 -> ifOperStatus = 1
--base: Walking ifMtu
--snpd: [email protected]: -> 1 -> ifMtu = 65536
--snpd: [email protected]: -> 2 -> ifMtu = 1500
--snpd: [email protected]: -> 3 -> ifMtu = 1500
--base: Walking ifSpeed
--snpd: [email protected]: -> 1 -> ifSpeed = 10000000
--snpd: [email protected]: -> 2 -> ifSpeed = 1000000000
--snpd: [email protected]: -> 3 -> ifSpeed = 1000000000

If you see the following error after running the above command you need to make sure you have completed the SNMP change discussed in the starting of this tutorial.

ERROR: did not find any matching data in cfg file

Create and index file for the webserver

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

You can access MRTG using the following URL


Output looks as follows


Sponsored Link

Related posts

Leave a comment

Your email address will not be published. Required fields are marked *