| English | 日本語 |

Tokyo Linux Users Group

Author: Josh Glover

Do You Have MRTG?

In a shell, type:

which mrtg

This should return the path to mrtg, probably /usr/bin/mrtg. If it is found, continue to #Configuring MRTG. If it is not found, see Linux_Help:QND-Guides:Finding_and_Installing_Software

Configuring MRTG

To generate an mrtg.cfg file, you can use the cfgmaker program (included in the MRTG distribution). In a shell, type:

su - root
mkdir /usr/local/mrtg
cfgmaker --global 'WorkDir: /usr/local/mrtg' \
         --global 'Options[_]: bits,growright' \
         --output /etc/mrtg.cfg \
         community@router.my.domain

In the second command, you need to change the WorkDir directive to reflect the path where you want MRTG to generate its graphs and HTML pages. If you are running a webserver, it might make sense to have MRTG use a subdirectory of htdocs. The Red Hat RPM suggested in this QND Guide actually creates the /var/www/html/mrtg directory, which is probably acceptable if you have installed Apache from the Red Hat RPM as well.

You will also need to change the bit of the command that says 'community@router.my.domain' to reflect the community string and hostname or IP address of whichever piece of networking hardware you will be using MRTG to monitor.

For more on cfgmaker, type into a shell:

man cfgmaker

Letting MRTG Grab its Data

In a shell, type:

su - root
crontab -e

This will bring up root's crontab in a text editor (corresponding to your EDITOR environment variable). At the bottom, add the two lines:

# Grab data for MRTG every five minutes
*/5 * * * * /usr/bin/mrtg /etc/mrtg.cfg

This will run the MRTG script every five minutes, using the config file that you created in #Configuring MRTG. If your mrtg script is installed in a difference place (type

which mrtg

to find out), replace the /usr/bin/mrtg with that path. Likewise, if you saved your config to a file other than /etc/mrtg.cfg, substitute that file above.

View the Results

Congratulations, you should be done. Fire up a web browser and point it at the directory (or URL, if you are running a webserver and you chose to put your MRTG data in its documents tree) that you specified in #Configuring MRTG. You should see plenty of colourful graphs.

References

  1. For more information on MRTG, see:
    1. http://people.ee.ethz.ch/~oetiker/webtools/mrtg/
    2. http://people.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg.html
  2. For more information on SNMP (Simple Network Management Protocol, which MRTG uses to get its data), see:
    1. ftp://ftp.isi.edu/in-notes/rfc1157.txt
    2. http://www.rescomp.berkeley.edu/about/training/senior/progs/SNMP-HOWTO/SNMP-HOWTO.html
    3. http://www.cisco.com/univercd/cc/td/doc/product/software/ios121/121cgcr/fun_c/fcprt3/fcd301.htm#xtocid176251
  3. For more information on setting up MRTG to monitor Cisco hardware, see:
    1. http://www.cisco.com/univercd/cc/td/doc/cisintwk/intsolns/dialsol/nmssol/mrtg.htm
  4. And finally, for more information on enabling and configuring SNMP on Cisco hardware (you *do* use Cisco, right?), see:
    1. http://www.cisco.com/univercd/cc/td/doc/cisintwk/intsolns/dialsol/nmssol/snmpios.htm
    2. http://www.cisco.com/univercd/cc/td/doc/product/software/ios121/121cgcr/fun_c/fcprt3/fcd301.htm
    3. http://www.cisco.com/univercd/cc/td/doc/product/software/ios121/121cgcr/fun_c/fcprt3/fcd301.htm

Chasing Dependencies

If you are reading this, you must be having a problem with dependencies that is keeping MRTG from installing. If this is not the case, stop reading this appendix.

The steps that you must follow to resolve your dependencies will again differ based on which distribution you run.

Red Hat, Mandrake, or other RPM-based Linux distro

The mrtg-2.9.17-3.i386.rpm RPM depends on the gd-devel package for generating the graphs. gd-devel has a few dependencies of its own. To fix the dependency problems, try the following steps:

  1. In a shell, type:
    rpm -q freetype-devel

    If the freetype-devel package is found, move onto the next step. If not, download the freetype-2.0.9-2.i386.rpm and freetype-devel-2.0.9-2.i386.rpm RPMs. In a shell, change to the directory where you downloaded the RPMs and type:

    su - root
rpm -Uvh freetype-2.0.9-2.i386.rpm freetype-devel-2.0.9-2.i386.rpm

    If the RPMs install with no problems, move onto the next step. If not, turn to your LUG.

  2. In a shell, type:
    rpm -q libjpeg

    If the libjpeg package is found, move onto the next step. If not, download libjpeg-6b-19.i386.rpm. In a shell, change to the directory where you downloaded the RPM and type:

    su - root
rpm -Uvh libjpeg-6b-19.i386.rpm

    If the RPM installs with no problems, move onto the next step. If not, turn to your LUG.

  3. Download gd-1.8.4-4.i386.rpm and gd-devel-1.8.4-4.i386.rpm files. In a shell, change to the directory where you downloaded the RPMs and type:
    su - root
rpm -Uvh gd-1.8.4-4.i386.rpm gd-devel-1.8.4-4.i386.rpm

    If the RPMs install with no problems, return to Step 2 and try again. If not, turn to your LUG.

MRTG