Since most
people run a Linux box as a server, there tends to be alot of interest
in collecting statistics and figures of the bandwidth that is used
through the system, this is where data logging and graphing software
becomes rather handy, namely MRTG (Multi Router Traffic
Grapher).
"The
Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic
load on network-links. MRTG generates HTML pages containing graphical
images which provide a LIVE visual representation of this traffic.
Check http://www.ee.ethz.ch/stats/mrtg/
for an example. MRTG is based on Perl and C and works under UNIX
and Windows NT. MRTG is being successfully used on many
sites around the net."
In order to
install MRTG successfully on your system, you will also need SNMPD
(this is where MRTG collects its information from), you should download
and install the latest version of SNMPD, for example here we used
ucd-snmp-4.2.5-7.72.0.i386.rpm
from www.rpmfind.net which
is for a Red Hat 7.2 system (used for this installation). To install
the latest rpm of SNMPD simply use the upgrade command of the rpm
program, e.g. rpm -Uvh ucd-snmp-4.2.5-7.72.0.i386.rpm.
Once you have installed SNMPD simply create the configuration file,
/etc/snmp/snmpd.conf and
make entries as follows (where <username>
is the username you wish to use for access to SNMPD information):
com2sec <username>-snmpd default <username>-snmpd
group <username>-snmpd v1 <username>-snmpd
group <username>-snmpd v2c <username>-snmpd
group <username>-snmpd usm <username>-snmpd
view all included .1 80
access <username>-snmpd "" any noauth exact all none none
After entering
the above information save the file the next best thing is to add
an entry to your firewall script to deny access to port 161 (the
SNMPD port) from any IP Address that is external to your network,
that is you only want to allow access by the server and your clients
on the network (192.168.0.* machines for example). When you have
safely blocked the port then it is time to start SNMPD by typing
/usr/sbin/snmpd (or
the appropriate location of the daemon on your system).
Now that SNMPD
is installed, configured and running it is time to move onto MRTG,
you can download the latest source code from the MRTG home page
(www.mrtg.org) or directly from
the download page: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/.
Here we used mrtg-2.9.21.tar.gz
from the MRTG site, once you have downloaded the latest file you
must extract the source, tar
-xzvf mrtg-2.9.21.tar.gz, then once your in the newly created
directory (cd mrtg-2.9.21/)
you must ./configure
MRTG for your system. Once that is done you need to make
and then make install
(must be logged in as root for this).
When MRTG has
finished installing on your system all that is left to do is create
a configuration file before you can run it, to create the default
configuration is rather simple using the cfgmaker
that is provided, simply enter the following (where <username>
is the same as used in installing SNMPD and <machine>
is either the IP Address or Hostname of the system):
cfgmaker --global 'WorkDir: /var/www/html/mrtg' \
--global 'Options[_]: bits,growright' \
--output /home/mrtg/cfg/mrtg.cfg \
<username>-snmpd@<machine>
If you wish
to run MRTG as a daemon (this is advisable, as it will constantly
generate information and statistics for you without being run each
time), then you will need to edit the configuration file (home/mrtg/cfg/mrtg.cfg)
and add RunAsDaemon: Yes
to the line above WorkDir.
It is now time
to run MRTG (first time will possibly generate errors as no output
files or data exists), /usr/local/mrtg-2/bin/mrtg
/home/mrtg/cfg/mrtg.cfg will start MRTG using the configuration
file that you created, you may also like to generate an index file
for the html, this is done by typing: /usr/bin/indexmaker
--output=/var/www/html/mrtg/index.html /home/mrtg/cfg/mrtg.cfg.
The only thing
that is now left is to customise the look and feel of the output
generated, this can be done by manually editing the configuration
file, the best way would be to look on the Internet for samples
and adapt them to your needs, once you are satisfied with the way
MRTG works then you can leave it to do its job and you now have
constant information that is up-to-date and easy to read in regards
to your bandwidth etc.
|