Sunday, October 26, 2008

How setup da MRTG 2.16.2 to Windows

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.

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%;...

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


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.

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

MAKE MRTG RUN ALL THE TIME

Starting MRTG by hand every time you want to run it is not going to make you happy I guess.

There is a special option you can set in the MRTG configuration file so so that MRTG will not terminate after it was started. Instead it will wait for 5 minutes and then run again.

Add the option

 RunAsDaemon: yes

to your mrtg.cfg file and start it with:

 start /Dc:\mrtg-2.16.2\bin wperl mrtg --logging=eventlog mrtg.cfg

Additional Prerequisites


Preparation

Please complete the following steps before starting the installation:

  • Copy srvany.exe and instsrv.exe to c:\mrtg\bin\ (your MRTG bin directory).
  • Create a file called mrtg.reg anywhere on your system and paste the following content into it:

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRTG\Parameters]
     "Application"="c:\\perl\\bin\\wperl.exe"
    "AppParameters"="c:\\mrtg\\bin\\mrtg --logging=eventlog c:\\mrtg\\bin\\mrtg.cfg"
    "AppDirectory"="c:\\mrtg\\bin\\"

Service Installation

Once again, assuming that MRTG is already fully installed and configured on the target system under c:\mrtg\ the following steps are necessary to setup MRTG as a service.

Using the command prompt go into the temporary directory where you unzipped the package. When there type the following command to create a service named "MRTG" in the Windows Services management console:

instsrv MRTG c:\mrtg\bin\srvany.exe

Now you need to create the App* entries required for the new service. You can do this by either right-clicking on the mrtg.reg file and selecting 'merge' or by running the following command:

 regedit /s mrtg.reg







No comments:

BlogCatalog

Technology Blogs - BlogCatalog Blog Directory