| Date: | May 25 2000 08:53:23 EDT |
| From: | [EMAIL PROTECTED] |
| Subject: | [redewan] MRTG - Tambem em Windows98 |
MRTG for Windows 95 and 98by Jeff Liebermann. Ver 1.10IntroductionMRTG (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 client machine using localhost for testing.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 PERLDownload WIN32 Perl 5.003 or later from: here. Copy PW32i315.EXE to the root directory of your hard disk. When you run this program, it will unarchive itself to C:\PERL and run the installation program.Add C:\PERL\BIN to the PATH= line in AUTOEXEC.BAT. If no path is specified, add: PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\PERL\BIN;Test with: ECHO PRINT "Hello World" | PERLIt should display Hello World and not hang on exit. There are other binary ports of Perl5 available on the net. Download and Install MRTGDownload MRTG-2.8.5 from here.Copy MRTG-2_8_5.ZIP to C:\ (root directory) of your hard disk. When this is unzipped, it will create a directory called C:\MRTG-2.8.5. 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_8_5.ZIP
Verify that C:\MRTG-2.8.5 directory was properly created and includes
various sub directories.
You may erase the ZIP file with: DEL MRTG-2_8_5.ZIPThe MRTG program is now installed. Edit the MRTG script file.Edit the file:C:\MRTG-2.8.5\RUN\MRTGand change the lines from: $main::OS = 'UNIX';
#$main::OS = 'NT';
to:
#$main::OS = 'UNIX';
$main::OS = 'NT';
No other editing is required. You can use W95/98 NOTEPAD or DOS
EDIT to do this. Do not use WORDPAD.
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 localhostCut out the following code or download it from here and save it as UPTIME.PL in the C:\MRTG-2.8.5\RUN 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:
PERL UPTIME.PL It should display the uptime of your machine. Check the C:\WINDOWS\HOSTS File.Create or edit the file C:\WINDOWS\HOSTS that should contain the line:127.0.0.1 localhostnear 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 LOCALHOSTIt should return something like: Pinging mbay84.cruzio.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<10ms 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=128Localhost must work in order to monitor your own traffic. Create a Simple MRTG.CFG Configuration Test File.Run: C:
CD \MRTG-2.8.5\RUN
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 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.CFGYou 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 IE4 "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.
If you are not running a local web server, keep it simple and instead use just: WorkDir: C:\MRTG
Options[_]: growright, unknaszero
WithPeak[_]: wmy
Create a corresponding empty C:\MRTG directory.
You will need to copy the graphics to the WorkDir. Run: COPY C:\MRTG-2.8.5\IMAGES\*.GIF C:\MRTGIt should say 4 files copied. Run it First Manually.Run:PERL C:\MRTG-2.8.5\RUN\MRTG C:\MRTG-2.8.5\RUN\MRTG.CFGYou will get some errors about "Can't remove ..." This is normal. Run the above command line twice again until the errors disappear. Check the WorkDir for the output files. View the Results.Start your Netscape, Opera or IE browser. Open File:C:\MRTG\localhost.2.htmlYou should see a familiar MRTG page with 3ea graphs. There will probably be no data to graph at this time. This is normal. Create a Batch File to Run.Create a file with a text editor called MRTGRUN.BAT in the C:\MRTG-2.8.5\RUN directory containing: @echo off
echo ==============================================
echo Hit [Alt][Tab] to return to Windows desktop.
echo Hit [Ctrl][Break] to manually cycle MRTG.
echo ==============================================
break on
:DOIT
C:\PERL\BIN\PERL C:\MRTG-2.8.5\RUN\MRTG C:\MRTG-2.8.5\RUN\MRTG.CFG
SLEEP.EXE 298
GOTO DOIT
The SLEEP.EXE program is the GNU sleep binary and can be downloaded
here
.
The 298 is the 300 seconds minus the approximate runtime of MRTG. This will vary with the speed of the machine and how busy the system appears. Create a shortcut on the desktop to this batch file by right clicking on the desktop > New > Shortcut that looks like this:
If you want MRTG to start automatically when the computer boots, be sure to add it to the Startup Collection. The easy way is to just copy the shortcut from the desktop to the C:\WINDOWS\START MENU\PROGRAMS\STARTUP directory. When running, MRTG will appear with the SLEEP program on the task bar. Every 5 minutes, the SLEEP will change to PERL and then RATEUP. Connect to your Internet Service Provider and generate some traffic. It will take some time to generate enough data for a useful graph. After a while, your graph will look something like this:
Ignore my lousy thruput. Ricochet was having a bad day. How to Stop MRTGTo stop MRTG data collection, right-click on the SLEEP button on the Task Bar and select CLOSE.Tweaking SNMPMicrosoft 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
Cut and save the following as SNMP.REG in the C:\MRTG-2.8.5\RUN
directory. It may also be downloaded from
here.
------------------------ 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.REGfrom 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. 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. Edit MRTG.CFG to fix.Netscape 4.04 does not refresh the page properly. 4.05 works fine. 4.5 and 4.6 also work fine. Netscape 4.0x [shift][refresh] only forces a refresh on the text. To force a graph refresh, right-click on a graph and chose [Refresh]. MRTG (actually Perl) grabs the keyboard when it runs. This can be major irritating if you are working when MRTG is run by System Agent. If I set System Agent to only run MRTG when the system is idle, perforance is erratic, because the logic Windows uses for idle detection is bizarre. Therefore, System Agent is not used. 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". W95 "System Monitor" can be used to monitor modem thruput. Programs > Accessories > System_Tools > System_Monitor Edit > Add > Dial-UP_Adapter > Bytes_Rcvd/Sec 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
|
