Multi Router Traffic Grapher (MRTG) is a great way to monitor SNMP traffic on your network. It’s a free tool, and it’s fairly simple to install. By monitoring daily/weekly/monthly/yearly traffic going in and out of your network, you can get a very good snapshot of how much traffic your network sees and what times of the day/week/month/year it spikes.

MRTG is available for Linux/UNIX and Windows. I’ll walk you through the steps of installing this system on a Ubuntu 16.04 Server platform. The entire process is done via the command line, but it isn’t terribly challenging. Once complete, you’ll have easy-to-read graphs that display your network SNMP traffic.

SEE: System Monitoring Policy (Tech Pro Research)

Installing dependencies

I assume you’re installing MRTG on a running LAMP server. If you haven’t installed LAMP, issue the following command to get that portion of the platform up and running.

sudo apt-get install lamp-server^

Beyond the actual server, the first thing you must do is install a couple of dependencies. Open your terminal window and issue the command:

sudo apt-get install snmpd snmp

Once that installs, the /etc/snmp/snmpd.conf needs to be edited. Open that file in your text editor of choice and change the line:

#rocommunity public localhost

to

rocommunity public localhost

Restart snmpd with the command:

sudo service snmpd restart

Installing MRTG

The MRTG software can be installed with a single command. From the terminal window, issue the following:

sudo apt-get install mrtg

During the installation, you’ll be prompted to change the ownership of the configuration file so it is only readable by the root user. When prompted (Figure A), tab to Yes and hit Enter on the keyboard.

Figure A

Setting up and configuring MRTG

Before we touch the configuration file, we need to first create a folder that will house MRTG. From the terminal, issue the command:

sudo mkdir /var/www/mrtg

Now back up the original MRTG config file with the command:

sudo cp /etc/mrtg.cfg /etc/mrtg.cfg.BAK

Open the /etc/mrtg.cfg file for editing and look to make sure the WorkDir line is set to:

WorkDir: /var/www/mrtg

Save and close that file.

Now we make use of the cfgmaker tool to rebuild the configuration file with the command:

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

Finally, we generate the HTML index file with the command:

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

Next we have to create a sites-available file. Issue the command sudo nano /etc/apache2/sites-available/mrtg.conf and then add the following to this new file:

Alias /mrtg "/var/www/mrtg/"
​
​
​Options None
​ AllowOverride None
​ Require all granted
​

Save and close that file. Enable the new site with the command sudo a2ensite mrtg and then restart Apache with the command sudo service apache2 reload. Once Apache reloads, you can point a web browser to http://IP_OF_SERVER/mrtg (IP_OF_SERVER is the actual IP address of your MRTG server) to see the MRTG page (Figure B).

Figure B

MRTG is now monitoring all incoming and outgoing SNMP traffic on your network. As long as that server is up and running, MRTG will do its thing.

An outstanding tool

MRTG is a very reliable way to keep track of network statistics for your business. It’s cheap, easy to install, and works like a champ. Get it up and running, and let it keep track of your networks’ comings and goings.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays