The Windows NT Guide to MRTG

by David S. Divins
updated by Steve Pierce, March 1999

To get MRTG to work on WindowsNT you need the following:  Latest version MRTG for NT, available here (look for mrtg-2.8.12.zip or better). The archive does also contain a precompiled copy of rateup for 386-NT. The binaries for Perl are available here; and Fiveminute.zip, available here. This guide is simply a basic overview for NT newbies; for more advanced documentation please see the mrtg home page.

Once you have downloaded these four files you are ready to begin. I suggest you do the following from the machine that will be running MRTG, which, in this case is also a web server. All examples are for doing things to a LOCAL machine.

First, Unzip MRTG to C:\mrtg-2.8.12 on the WindowsNT machine of your choice. Then, unzip fiveminute.zip to the mrtg directory.

Next, extract the Perl files to c:\perl on the same Windows NT machine. From the command prompt run c:\perl\bin\perlw32-install.bat.  Follow the on screen instructions (choose all the defaults).  This will properly install perl with all of the correct path statements. You want your system path statement to look something like this.

C:\Perl\bin;%SystemRoot%\system32;%SystemRoot%;C:\NTRESKIT;

You can manually check this by going to Control Panel/System/Environment

 

Now, this step is VERY important! Open the file c:\mrtg-2.8.12\mrtg in your favorite word processor, I suggest MSWord because Word will format the document so it is readable. Once this file is open you need to change lines 4 and 5 from:

$main::OS = 'UNIX';

#$main::OS = 'NT';

to

#$main::OS = 'UNIX';

$main::OS = 'NT';

This is the only editing you need to do to the actual mrtg file. This simply tells MRTG that your OS is NT. I can not emphasize enough that this need to be done and the file needs to be saved as mrtg, overwriting the distribution copy.

Now, you have successfully installed mrtg and perl.  Now it is time to walk through the mrtg.cfg.  Before we begin you need to know a few things, take an opportunity to gather the following information: The IP address and port number, if applicable, of the device you want to monitor.  If you want to monitor something other than bytes in and out, know the SNMPOID of what you want to monitor.  Finally you need to know the read-only SNMP community string for your device.  If you don't know it, try public, that is the default.

For the rest of this document we will be using device10.10.10.1 ( a CISCO Catalyst 5000) with Community string public.  We are interested in monitoring traffic on ports 3, 5, 10, and 24, and the CPU Load. Let's begin.

The first thing we do in setting up mrtg is by making a default config file. Get to a cmd prompt and change to the c:\mrtg-2.8.12 directory. Type the following command:

perl cfgmaker public@10.10.10.1 > mrtg.cfg

This creates an initial MRTG config file for you. If you have a Cisco router you can try the --vendor switch which will produce a more robust web page (seen soon).

If you get an error message like the following, your community name is probably wrong. This is a good time to get familiar with this error screen. Later, when we try more advanced monitoring we may run into similar screens but for different reasons.

Now, lets take a look at the mrtg.cfg file that was created.

In Perl a # is a comment, synonymous with REM in DOS and Blue text is my comments.

Add the following to the top of the mrtg.cfg file:

WorkDir: D:\InetPub\wwwroot\MRTG

This is where the web pages are created,usually a web root.


######################################################################
# Description: LCP SUWGB
# Contact: Administrator
# System Name: LC-Bridge
# Location: Here
#.....................................................................

Target[10.10.10.1.1]: 1:public@10.10.10.1 TargetDevice's IP Address:Interface Number:Community:IP Address
MaxBytes[10.10.10.1.1]: 1250000 This is the interface speed (Default is 10megabits; for 100Mbit devices use 12500000 and so on...)
Title[10.10.10.1.1]: LC-Bridge (sample.device): ether0
PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0 This section determines how the web page headers will look
</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ether0(1)</TD></TR>
<TR><TD>IP:</TD><TD>sample.device(10.10.10.1)</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE>

#---------------------------------------------------------------

Target[10.10.10.1.2]: 2:public@10.10.10.1
MaxBytes[10.10.10.1.2]: 1250000
Title[10.10.10.1.2]: LC-Bridge (): ulink0
PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0
</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ulink0(2)</TD></TR>
<TR><TD>IP:</TD><TD>()</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE>

#---------------------------------------------------------------

And that is a very basic mrtg config file. You can run this and see your results by typing:

c:\perl\bin\perl c:\mrtg-2.8.12\mrtg c:\mrtg-2.8.12\mrtg.cfg

It is normal to get errors, these are what they should look like.

Notice the numbers of the directory name are different in the screen shot. This screen shot was from an older version of MRTG.

If you take a look at those web pages they are not real exciting, yet. You need to have the mrtg files run every five minutes to produce the desired results. This is where fiveminute.zip comes in to play.

You need to start the Scheduler Service so it can run the batch files as a service in the background. From Control Panel/Services highlight "Schedule" and configure it to run automatic and have it log on with an admin account.

Fiveminute.zip adds around 289 entries into your at schedule. It Schedules three programs (A.bat, B.bat, and C.bat) to run at incrementing fifteen minutes; so a script runs every five minutes. You should have all three programs run the mrtg config file. This is all set up by default in fiveminute.zip but you can change it if necessary. The reason I have three scripts instead of one is in case you want to add non-mrtg scripts. I found this works best for my environment.

So from c:\mrtg-2.8.12 run 3at.bat

Now, every five minutes A.bat B.bat or C.bat will run. These are examples of the three batch files (they are all the same).

start c:\mrtg-2.8.12\mrtgkick.bat

And mrtgkick.bat looks like:

c:\perl\bin\perl c:\mrtg-2.8.12\mrtg c:\mrtg-2.8.12\mrtg.cfg

Congratulations! You are now monitoring traffic on a device of your choice. Now lets look at a config file to monitor what we wanted to on our mythical Cisco Cat 5000 -- utilization on ports 3, 5, 10, and 24, and the CPU Load, which will show us nonstandard mrtg configurations as well as more options..

WorkDir: D:\InetPub\wwwroot\MRTG

######################################################################
# Description: LCP SUWGB
# Contact: Administrator
# System Name: LC-Bridge
# Location: Here
#.....................................................................

Target[10.10.10.1.1]: 3:public@10.10.10.1
MaxBytes[10.10.10.1.1]: 1250000
Title[10.10.10.1.1]: LC-Bridge (sample-device): ether0
PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0
</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ether0(3)</TD></TR>
<TR><TD>IP:</TD><TD>sample-device(10.10.10.1)</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE>

#---------------------------------------------------------------

Target[10.10.10.1.2]: 5:public@10.10.10.1
MaxBytes[10.10.10.1.2]: 1250000
Title[10.10.10.1.2]: LC-Bridge (): ulink0
PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0
</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ulink0(5)</TD></TR>
<TR><TD>IP:</TD><TD>()</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE>

#---------------------------------------------------------------

Target[10.10.10.1.1]: 10:public@10.10.10.1
MaxBytes[10.10.10.1.1]: 1250000
Title[10.10.10.1.1]: LC-Bridge (sample-device): ether0
PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0
</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ether0(10)</TD></TR>
<TR><TD>IP:</TD><TD>sample-device(10.10.10.1)</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE>

#---------------------------------------------------------------

Target[10.10.10.1.2]: 24:public@10.10.10.1
MaxBytes[10.10.10.1.2]: 1250000
Title[10.10.10.1.2]: LC-Bridge (): ulink0
PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0
</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ulink0(24)</TD></TR>
<TR><TD>IP:</TD><TD>()</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE>

#---------------------------------------------------------------

# Router CPU load %
Target[cpu.1]:1.3.6.1.4.1.9.2.1.58.0&1.3.6.1.4.1.9.2.1.58.0:public@10.10.10.1
RouterUptime[cpu.1]: public@10.10.10.1
MaxBytes[cpu.1]: 100
Title[cpu.1]: CPU LOAD
PageTop[cpu.1]: <H1>CPU Load %</H1>
#Title[cpu.1]: CPU Utilization
Unscaled[cpu.1]: ymwd
ShortLegend[cpu.1]: %
XSize[cpu.1]: 380
YSize[cpu.1]: 100
YLegend[cpu.1]: CPU Utilization
Legend1[cpu.1]: CPU Utilization in % (Load)
Legend2[cpu.1]: CPU Utilization in % (Load)
Legend3[cpu.1]:
Legend4[cpu.1]:
LegendI[cpu.1]:
LegendO[cpu.1]: &nbsp;Usage
Options[cpu.1]: gauge

This is a nice example of how to monitor any SNMP device if you know what OID you want to use. Once again, For an explanation of the more advance features of mrtg, please see Tobias's documentation.

Good Luck!


David S. Divins ddivins @ moon.jic.com

Steve Pierce MRTG @ HDL.com