HOWTO/Tutorial MRTG Graph Setup (Router/Switch)- SNMP Setup
The
following is a quick tutorial on how to setup MRTG (Multi Router
Traffic Grapher), and can be used to monitor routers, switches, and
servers. It can be used for a wide variety of monitoring capabilties,
but this will only cover bandwidth usage graphs.
This tutorial is for Linux/UNIX, and requires the following packages to be installed:
Perl
SNMP Installed on the device you are monitoring
1.
The first step is to install MRTG on the server you will be displaying
the graphs from (usually for a small setup a webserver). This can be
done one of the following ways:
Redhat:
up2date -i mrtg
FreeBSD:
cd /usr/ports/net-mgmt/mrtg
make
make install
The
next step after installing MRTG is to create a config file, this is
done using cfgmaker, which is included in the MRTG installation:
cfgmaker public@10.1.1.1 --global "WorkDir: /usr/local/apache/htdocs/mrtg" --output server.cfg
In the example above, there are several options which need to be modified based upon how your current setup is.
public@10.1.1.1
The
10.1.1.1 is the IP address of the device running SNMP, and the public
is the SNMP community. By default most devices have a default setting
of public, but this could be any name. If public does not work you
should login to the device and check what it is using for the SNMP
community.
"WorkDir: /usr/local/apache/htdocs/mrtg"
The directory /usr/local/apache/htdocs/mrtg
is where the MRTG html files will be placed. This includes all graphs,
and html files. This directory is ideally where your web server is
running, so you would be able to view these files over the network.
--output server.cfg
Server.cfg is the configuration file to be used by MRTG. This is usually stored in /etc/mrtg.conf
Using
cfgmaker, it will create a seperate page for each target (interface).
You can use indexmaker to view all targets on the one page:
indexmaker --output mainindex.htm server.cfg
This
will generate the file mainindex.htm using the server.cfg MRTG config
file. Inside the mainindex.htm there will be a summary of all
interfaces.
Running MRTG:
mrtg server.cfg
This
will generate files located in the WorkDir you specified earlier. To
use MRTG successfully you will need to run it at about 5 minute
intervals. This can be added to a cronjob, something like the following:
1,5,10,15,20,25,30,35,40,45,50,55,59 * * * * /usr/bin/mrtg /etc/server.cfg> /dev/null
Now
go to your web browser and view the mainindex.html, you will find that
MRTG has been polling your SNMPdevice and started generating graphs.
SNMP
has a lot of potential and is a great way to monitor devices, it can
even be setup running on a server to monitor such things as hard drive
usage, network usage, etc.
Please
note that this can be done very similarly on windows, but when running
more of the commands you must type perl before them. Also, windows does
not support cronjobs, so you will need set this up another way.