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

Portable

MRTG works on most UNIX platforms and Windows NT.

Perl

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.

Performance

Time critical routines are written in C .

GIF free Graphics

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

Customizability

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

RRDtool

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

Prerequisites

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

to

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

to

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 public@localhost > /etc/mrtg.cfg

--base: Get Device Info on public@localhost:
--base: Vendor Id: Unknown Vendor -- 1.3.6.1.4.1.8072.3.2.10
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd: public@localhost: -> 1 -> ifIndex = 1
--snpd: public@localhost: -> 2 -> ifIndex = 2
--snpd: public@localhost: -> 3 -> ifIndex = 3
--base: Walking ifType
--snpd: public@localhost: -> 1 -> ifType = 24
--snpd: public@localhost: -> 2 -> ifType = 6
--snpd: public@localhost: -> 3 -> ifType = 6
--base: Walking ifAdminStatus
--snpd: public@localhost: -> 1 -> ifAdminStatus = 1
--snpd: public@localhost: -> 2 -> ifAdminStatus = 1
--snpd: public@localhost: -> 3 -> ifAdminStatus = 1
--base: Walking ifOperStatus
--snpd: public@localhost: -> 1 -> ifOperStatus = 1
--snpd: public@localhost: -> 2 -> ifOperStatus = 1
--snpd: public@localhost: -> 3 -> ifOperStatus = 1
--base: Walking ifMtu
--snpd: public@localhost: -> 1 -> ifMtu = 65536
--snpd: public@localhost: -> 2 -> ifMtu = 1500
--snpd: public@localhost: -> 3 -> ifMtu = 1500
--base: Walking ifSpeed
--snpd: public@localhost: -> 1 -> ifSpeed = 10000000
--snpd: public@localhost: -> 2 -> ifSpeed = 1000000000
--snpd: public@localhost: -> 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

http://mrtg

Output looks as follows

1

Sponsored Link

Related posts

Leave a comment

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