The MRTG 2.16.2 Windows Installation Guide Rumi, December 22, 2009December 22, 2009 SYNOPSIS Installing MRTG on a Windows box is not quite as “click and point” as some might want it to be. But then again, it is not all that difficult if you follow the instructions below. My setup was MRTG 2.16.2 Perl 5.8.8.819 PREREQUISITES To get MRTG to work on Windows you need the following: A current copy of Perl. For Example ActivePerl 5.8.8 from ActiveState http://www.activestate.com/store/activeperl/download/ The latest version of MRTG from http://oss.oetiker.ch/mrtg/pub. Look for mrtg-2.16.2.zip or better. The archive also contains a precompiled copy of rateup.exe for Win32. INSTALLING 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.16.2 on the Windows machine of your choice. Next Install Perl on the same Windows machine. You might want to make sure that the Perl binary directory is listed in your system path. C:\Perl\bin;%SystemRoot%\system32;%SystemRoot%;... You can manually check this by going to [Control Panel]->[System]->[Environment] To see if everything is installed properly you can open a Command Shell and go into c:\mrtg-2.16.2\bin. Type: perl mrtg This should give you a friendly error message complaining about the missing MRTG configuration file. Now, you have successfully installed MRTG and Perl. CONFIGURING MRTG Now it is time to create a configuration for MRTG. But before we begin you need to know a few things. Take an opportunity to gather the following information: The IP address or hostname and the SNMP port number, (if non standard), of the device you want to monitor. If you want to monitor something other than bytes in and out, you must also 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 device 10.10.10.1 ( a CISCO Catalyst 5000) with Community string public. We are interested in monitoring traffic, and the CPU load. Let’s begin. The first thing we do in setting up MRTG is making a default config file. Get to a cmd prompt and change to the c:\mrtg-2.16.2\bin directory. Type the following command: perl cfgmaker public@10.10.10.1 --global "WorkDir: c:\www\mrtg" --output mrtg.cfg This creates an initial MRTG config file for you. Note that in this file all interfaces of your router will be stored by number. Unfortunately, these numbers are likely to change whenever you reconfigure your router. In order to work around this you can get cfgmaker to produce a configuration which is based on Ip numbers, or even Interface Descriptions. Check cfgmaker If you get an error message complaining about no such name or no response, your community name is probably wrong. Now, let’s take a look at the mrtg.cfg file that was created. In Perl, a # is a comment, synonymous with REM in DOS. Add the following to the top of the mrtg.cfg file: WorkDir: c:\www\mrtg This is where the web pages are created, usually a web root. ###################################################################### # Description: LCP SUWGB # Contact: Administrator # System Name: LC-Bridge # Location: Here #..................................................................... TargetDevice’s IP Address:Interface Number:Community:IP Address Target[10.10.10.1.1]: 1:public@10.10.10.1 This is the interface speed (Default is 10 megabits; for 100Mbit devices use 12500000 and so on…) MaxBytes[10.10.10.1.1]: 1250000 Title[10.10.10.1.1]: LC-Bridge (sample.device): ether0 This section determines how the web page headers will look 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(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’s a very basic MRTG config file. You can run this and see your results by going into the c:\mrtg-2.16.2\bin directory and typing: perl mrtg mrtg.cfg It is normal to get errors for the first two times you run this command. The errors will alert you about the fact that there have not been any log files in existence before. If you take a look at those web pages they are not very exciting (yet). You need to have the MRTG files run every five minutes to produce the desired results. Just run it again after a few minutes. You should now be able to see the first lines in your graphs. 5 Mins Graph Updates: This is the tricky part I just added up to my own flavor 😉 Copy the following code and save the file on a text file and I saved it as “start.pl” and save path will be MRTG\BIN directory. This will actually updates the graph in every 5 mins. $interval=300; while (1) { sleep( $interval – time() % $interval ); system ‘perl mrtg mrtg.cfg’; } Now execute start.pl by double clicking on it. A black command prompt window alike will appear- keep it running. The only problem is, every time you restart the server either you have to double click on this start.pl or once log in need to copy the file in start directory. It will not behave like a regular windows service- you need at least to login! However, I used third party software like “Alwaysup” and make the script to the service list. So, literally it’s working now as a service!!! 🙂 Handy isn’t it???? Other than 5 min graph update, content source: http://oss.oetiker.ch/mrtg/doc/mrtg-nt-guide.en.html Configurations (Windows)