Upcoming Events

Cloud Connect
Santa Clara
Feb 13-16, 2012

Cloud Connect brings together the entire cloud eco-system to better understand the transformation we're experiencing and promises to be the defining event of the cloud computing industry. Learn about the latest cloud technologies and platforms from thought leaders in Cloud Connect’s comprehensive conference.

Register Now!

More Events »

Subscribe to Newsletter

  • Keep up with all of the latest news and analysis on the fast-moving IT industry with Network Computing newsletters.
Sign Up
Network + Systems Management
W O R K S H O P  
MRTG Monitors What's Brewing<

  April 3, 2003
  By Bruce Boardman


>> continued from previous page

Stringing It Together
TOC Issue TOC
Printer Print full article
Printer Print this page
Printer Download as PDF
E-Mail E-Mail this URL
Discuss Discuss this article
flame author Flame the author
 
  In this article
arrow
Introduction
arrow
Stringing It Together

Configuring MRTG can be challenging at first, so before you start, make sure you understand the syntax of an MRTG configuration file. A configuration file feeds the MRTG tool information it needs to target a particular device, along with its interfaces and statistics. It also provides the SNMP community string for accessing the SNMP agent on the monitored device, and it specifies where and how the HTML page gets created. The illustration below shows what a portion of a configuration file looks like.

The most important parts of a configuration file are the target, description and WorkDir keywords. The target parameters specify the IP address, port, OID and SNMP community of the monitored device. In the example shown, we didn't specify an OID, so MRTG by default monitors ifInOctetes and ifOutOctets.



One of the most common errors for new MRTG users is incorrectly specifying the community string. It's a good idea to start with "public" as your community string (much to the chagrin of your security administrators). If you experience problems gathering performance data, verify your community. You also need to specify a work directory so MRTG can place the log, HTML and PNG files.

You can create the basic format with a minimum of parameters, as in the example shown, using the MRTG's CFGMAKER script. CFGMAKER checks the SNMP MIB variable of the monitored device and the supplied community string, creating a ready-to-use configuration file. You can edit the file manually if you require more advanced parameters, such as additional report titles, plotting maximum values and changing the target SNMP OID.

CFGMAKER, like all default MRTG executables, is executed as a command line. This won't be a problem if you're used to Linux or Unix, but it may trip you up if you come from a Windows background.

Don't Stray From the Path

Sites to See
You also need to know how to set the paths for the configuration file. After you download MRTG, the directory is unzipped to a location off the C: directory, with a name like MRTG-2.9.25. Do yourself a favor and rename the directory something simple like "MRTG"--you won't have to worry about potential typos with that default name.

Executing MRTG scripts like CFGMAKER also can cause problems if you don't have a handle on the paths. Because MRTG is written in PERL, it needs a PERL interrupter like ActivePerl. This means that when you run MRTG or CFGMAKER, the command has to begin with the PERL executable--PERL must be in the path environment of the operating system, and ActivePerl automatically places it there for you.

If you don't have experience with path statements, it's safer to begin executing MRTG from within the MRTG\BIN directory, where, by default, the user and configuration files are stored. To place your configuration files in a separate directory, you have to set the path to that directory.

In the example shown, a configuration file myswitch.cfg is created in the directory config in mrtg for the device at IP address 10.10.10.1 with a community string of public. The output files and graphs are going into the directory workdir in mrtg:

C:\mrtg\bin>Perl cfgmaker  public@10.10.10.1--
global "WorkDir: c:\mrtg\workdir"--output c:\mrtg\config\myswitch.cfg

To test MRTG, run the following command. Be sure the path points to the correct configuration file:

C:\mrtg\bin> Perl mrtg c:\mrtg\config\myswitch.cfg

This command runs the MRTG script only one time. For it to run continuously, you need to substitute PERL with WPERL, which comes with MRTG. As long as your system runs MRTG with WPERL, you can create graphs like those shown on the previous page.

If you want your MRTG tool to start automatically when you fire up your MRTG server, just create a shortcut in the start-up folder or use a daemon. With Microsoft's RunAsService utility, or freeware products such as FireDaemon or MRTG Statistic Updater, the daemon can run under Windows as a service without having to log on to Windows.

When MRTG experiences a failure, it logs the problem for you. These log messages can be very useful: For example, when we were editing configuration files, the MRTG log recorded an application error and pinpointed which file was locked. It also recorded which line of code within the MRTG configuration file was being accessed.

All in all, MRTG is a simple and inexpensive way to manage a few dozen interfaces. It can easily monitor the backbone router and switch ports for most businesses. MRTG gets complicated, however, when you increase the number of ports you want to monitor. The more ports, the larger the hardware you need to do the monitoring. The biggest challenge with MRTG is collecting all the port information into a coherent picture of your network's performance. If you're willing to invest the time to configure MRTG properly, you'll find it a reliable and consistent tool for monitoring your network.

Bruce Boardman is executive editor of Network Computing. Write to him at bboardman@nwc.com.

Post a comment or question on this story.


start top  Introduction Stringing It Together

Research and Reports

Hypervisor Derby
August 2011

Network Computing: August 2011

TechWeb Careers