MRTG for Windows 95, 98, and ME

by Jeff Liebermann. Ver 3.06   for MRTG version 2.9.21


Introduction

MRTG (Multi-Router Traffic Grapher) is used to generate traffic graphs for network connections on a Windows 95/98 workstation. No external router is required for testing. The following are the basic instructions needed to download, install, configure, and test, MRTG on a Windows 95/98/ME client machine using localhost for testing.  These instructions will NOT work with NT4 or W2K.

Please perform the following steps in roughly the order shown. Be sure to test each part before blundering onward. Some knowledge of MSDOS command line operations is assumed. You will need a long file name compatible UNZIP program and a text editor. PKUNZIP 2.04 will not work. 


Download and Install PERL

Download Active Perl 5.6.x. for Windoze MSI (8MB).  When you run the install, it will unarchive itself to C:\PERL.  You will need to update your Microsoft Installer to 2.0.  The Active Perl install will complain if it needs the new installer. 

Test with:

        ECHO PRINT "Hello World" | PERL
It should display Hello World and not hang on exit.  If you get some kind of  "Cannot find Perl" error message, fix your PATH= line your AUTOEXEC.BAT file. 

Fix a Perl Bug

ActiveState Perl 5.6 has a bug in the FindBin.pm module which mangles the directory delimiters and causes RealBin::Bin to incorrectly return:
c:/mrtg-2.9.21/bin\rateup.exe
This results in an "Invalid command or filename" error message later when MRTG is run.  Almost all the email I have received involve this error message.

The fix is to add 4 lines near the bottom of:

c:\perl\lib\findbin.pm
$RealBin = abs_path($RealBin) if($RealBin);   ## existing line
   if ($IsWin32)
   {
      $Bin =~ s/\//\\/g;
   }

Of course, make a backup of findbin.pm before tweaking.
That's a "tilde" after the equal sign in the $Bin line.

If you are unable to use a text editor, you can download a fixed copy of FindBin.pm from here.

A new feature of Active State Perl 5.6.1 build 633 is that it no longer belches "Invalid command or filename".  It now hangs the perl program, locks up the MSDOS window, prevents one from removing the mrtg.cfg_l lock file, and requires a Windoze reboot to recover.


Download and Install MRTG

Download MRTG-2.9.21
If MRTG had been updated, check for updates here.

Copy MRTG-2.9.21.ZIP to C:\ (root directory) of your hard disk. When this is unzipped, it will create a directory called C:\MRTG-2.9.21. This is where most everything will be installed. Do not rename this directory. If the MRTG version changes, change the version references in this document.
Run:
        C:
        CD \
        UNZIP -d MRTG-2.9.21.ZIP
Verify that C:\MRTG-2.9.21 directory was properly created and includes various sub directories.

You may want to erase the ZIP file with:

        DEL MRTG-2.9.21.ZIP
The MRTG program is now installed. 

Install SNMP Client Network Services.

Install SNMP services and agent.  This will allow you to monitor and graph your own machine.
             Start > Settings > ControlPanel > Network > Add > Service > Microsoft > SNMP
If SNMP client services does NOT appear on the list of Microsoft services to Add, download the file W95SNMPZP.EXE from: here.
Copy this file into an empty directory.
Run: W95SNMPZP.EXE to extract the files.
             Start > Settings > ControlPanel > Network > Add > Service > HaveDisk > Browse
Point to the SNMP.INF file in the directory with the SNMP stuff. Click OK. Windows will ask to reboot. Say yes. 

Testing SNMP on localhost

Cut out the following code or download it from here and save it as UPTIME.PL in the  C:\MRTG-2.9.21\LIB\MRTG2 directory.
------------------- cut here ----------------------------------

use BER;
use SNMP_Session;
# Return the uptime of the localhost to test SNMP
$host = "localhost";
$community = "public";
$oid = encode_oid(1,3,6,1,2,1,1,3,0);    # Uptime
$session = SNMP_Session->open ($host, $community, 161)
    || die "Can't open SNMP session to localhost";
$session->get_request_response ($oid);
($bindings) = $session->decode_get_response ($session->{pdu_buffer});
($binding,$bindings) = &decode_sequence ($bindings);
($oid,$value) = &decode_by_template ($binding, "%O%@");
print &pretty_print($oid)," => ", &pretty_print ($value), "\n";

------------------- cut here -----------------------------------
Run it with:

        CD \MRTG-2.9.21\LIB\MRTG2
        PERL UPTIME.PL

It should display the uptime of your machine.  If it does NOT work, you may not have SNMP properly installed on your Windows machine.


Check the C:\WINDOWS\HOSTS File.

Create or edit the file C:\WINDOWS\HOSTS that should contain the line:
        127.0.0.1  localhost
near the top. This file may already exist and may have other entries. The localhost line must be present.

Open an MSDOS window and run:

        PING LOCALHOST
It should return something like:
  Pinging karma.learnbydestroying.com [127.0.0.1] with 32 bytes of data:
  Reply from 127.0.0.1: bytes=32 time=1ms TTL=128
  Reply from 127.0.0.1: bytes=32 time=1ms TTL=128
  Reply from 127.0.0.1: bytes=32 time=1ms TTL=128
  Reply from 127.0.0.1: bytes=32 time=1ms TTL=128
Localhost must work in order to monitor your own traffic. 

Create a Simple MRTG.CFG Configuration Test File.

Run:
        C:
        CD \MRTG-2.9.21\BIN
        PERL CFGMAKER public@localhost
This should fill the screen with something like:
  Target[localhost.2]: 2:public@localhost
  MaxBytes[localhost.2]: 10000
  Title[localhost.2]: JEFFLIEB (mg130-151.ricochet.net): PPP Adapter.
  PageTop[localhost.2]: <H1>Traffic Analysis for PPP Adapter.
   <H1>
   <TABLE>
     <TR><TD>System:</TD><TD>JEFFLIEB in Santa Cruz</TD></TR>
     <TR><TD>Maintainer:</TD><TD>Jeff Liebermann</TD></TR>
     <TR><TD>Interface:</TD><TD>PPP Adapter. (2)</TD></TR>
     <TR><TD>IP:</TD><TD>mg130-151.ricochet.net (204.179.130.151)</TD></TR>
     <TR><TD>Max Speed:</TD>
         <TD>10000.0 Bytes/s (ethernetCsmacd)</TD></TR>
   </TABLE>
To generate this output requires that PERL SNMP and W95/98/ME networking are working. Troubleshoot according to the error messages generated.

Note that the output will change depending upon which network interface (PPP, ethernet) is active and which ISP is active. Try it connecting to the internet via various ISP's and note the differences. When it looks reasonable, run:

        PERL CFGMAKER public@localhost > MRTG.CFG
You may find a problem with the MaxBytes: line. For some unknown reason, my systems decided that the MaxBytes: of my radio modem was 1200 Bytes/sec. I edited the above MRTG.CFG file and increased the speed to an overly optimistic 10,000 Bytes/sec. 

Tweaking the MRTG.CFG File.

MRTG needs to know where to dump its output. If you are running the IE "Personal Web Server", edit MRTG.CFG and add at the top:
        WorkDir: C:\InetPub\wwwroot\mrtg
        Options[_]: growright, unknaszero
        WithPeak[_]: wmy
Note the space after the comma in the Options[_] line.  This is required. Make sure that the WorkDir directory exists.  There should be no spaces between the left margin and the various entries.

If you are not running a local web server, keep it simple and instead use just:

        WorkDir: C:\MRTGDATA
        Options[_]: growright, unknaszero
        WithPeak[_]: wmy
Create a corresponding empty C:\MRTGDATA directory.
You will need to copy the graphics to the WorkDir. Run:
        COPY C:\MRTG-2.9.21\IMAGES\*.* C:\MRTGDATA
It should say 8 files copied. 

Run it First Manually.

Run:
C:
CD \MRTG-2.9.21\BIN
PERL MRTG MRTG.CFG
In earlier versions, you may get some errors about "Can't remove ..." This is normal. You should not get these errors in MRTG 2.9.17 and above. Run the above command line twice again until the errors disappear. Check the WorkDir for the output files. If you get one or more "Bad command or filename" errors, or Perl just hangs requiring a reboot to recover, go to the section labeled "Fix a Perl Bug" and follow the instructions. 

View the Results.

Start your Netscape, Opera or IE browser. Open File:
C:\MRTGDATA\localhost_12345678.html
You should see a familiar MRTG page with 3ea graphs. There will probably be no data to graph at this time. This is normal. 

Starting MRTG

To daemonize (run in the background) MRTG, edit the mrtg.cfg file and add near the top of the file:
RunAsDaemon: Yes
Interval: 5
Open an MSDOS window.  From the command line, run:
CD \MRTG-2.9.21\BIN
PERL MRTG MRTG.CFG
You should get the message:
Daemonizing MRTG...
Do Not close this window. Or MRTG will die
In past versions, MRTG would display an obnoxious windows box every time MRTG runs.  This was fixed in MRTG version 2.9.17 (hurrah).
For those wishing instructions on how to run MRTG without using the RunAsDaemon: Yes  feature, see:
          http://members.cruzio.com/~jeffl/mrtg/docs/w95batch.htm

To stop MRTG, open the window labeled PERL, and hit <ctrl>C or <ctrl><Break>.

If you make changes to mrtg.cfg, you should stop MRTG and restart.


Tweaking SNMP

Microsoft did not bother to supply a way to set the sysContact, sysLocation and Community name. The usual way is to use REGEDIT which is rather overkill. It's much easier from the command line.

Backup your existing registry with:

        CD \WINDOWS
        ATTRIB -r -h -s SYSTEM.DAT
        COPY SYSTEM.DAT SYSTEM.OLD
For Windows 98 and Windows ME, cut and save the following as SNMP.REG in the   C:\MRTG-2.9.21\BIN  directory.
------------------------  cut here  -------------------------
REGEDIT4

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP]
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters]
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\EnableAuthenticationTraps]
"switch"=hex:01,00,00,00

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\ExtensionAgents]
"1"="SOFTWARE\\Microsoft\\RFC1156Agent\\CurrentVersion"

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers]

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration]

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent]
"sysContact"="Your Name Here"
"sysLocation"="Your Location Here"
"sysServices"=hex:4c,00,00,00

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities]
"1"="public"
------------------------  cut here  -------------------------
For Windows 95, cut and save the following as SNMP.REG in the C:\MRTG-2.9.21\BIN  directory.
------------------------  cut here  -------------------------

REGEDIT4

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent]
"sysContact"="Your Name Here"
"sysLocation"="Your Location Here"
"sysServices"=hex:4c,00,00,00

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities]
"1"="public"

------------------------  cut here  -------------------------
Edit the file as required. I suggest you leave the sysServices and Communities alone.
Run:
        REGEDIT SNMP.REG
from the command line. It should say that the registry was properly updated. If you have an existing entry for localhost in your MRTG.CFG file, you will need to recreate it as the names in the header do not change automatically.

If SNMP appears to malfunctioning, try the reg files at:
      http://www.wtcs.org/snmp4tpc/snmp49x.htm
which are more detailed.


Notes and Problems.

Wrong MaxBytes value from cfgmaker. If your graph shows nothing, then MRTG is discarding returned values as being over the MaxBytes limit. Please edit MRTG.CFG to fix.

If MRTG or PING causes the modem to dial out looking for a DNS nameserver, disarm the monster by turning off "Dial on Demand" or by selecting "Connect to internet via local network".

If you get a Bad Command or Filename error messages, see the section on Fix a Perl Bug.

If MRTG hangs when you run from the command line, you are using Active State 5.6.1 build 633 and have failed to properly Fix a Perl Bug.  If you are unable to use a text editor, you can download a fixed copy of FindBin.pm from here.

If you get "Cannot find WorkDir" error, remove the spaces in front of the Workdir line in mrtg.cfg.

90% of the email I receive are the result of 2 problems.  Failure to properly edit or install FindBin.pm as in Fix a Perl Bug, and failure for SNMP to operate under the original version of Windoze 98 (4.00.1998).  The Perl bug can be fixed by following instructions.  The Windoze 98 problem is usually repaired by removing SNMP, rebooting, and re-installing SNMP, with the Network control panel tool.


References and Heavy Reading.


Miscellaneous Drivel and Administrivia.

The latest version of this page is here.

Email comments, corrections, additions and gratuities to Jeff Liebermann

  • Revision History