configuring MRTG-Part -1

Platform: - Windows 2000/2003 server, windows XP
Keywords: - Configuring MRTG on Windows
Author: - Dinesh Aggarwal

MRTG is a very good tool to monitor the bandwidth utilization

of your organization. Infact MRTG can be used to monitor anything that uses SNMP.
Here we will start from the very basic of how to install MRTG and then move forward to advanced topics.

First Install IIS on the machine on which MRTG needs to be installed. Update all Microsoft patches on it. Download pearl from

perl download

(Active Perl 5.6.1.638    Windows  

AS package

8.3MB

mrtg-2.11.1.zip 

3) First
Unzip MRTG to C:\mrtg-2.11.1 on the Windowsmachine 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.11.1\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

C:\Documents and Settings\Administrator>cd\
C:\>cd mrtg-2.11.1\bin
C:\mrtg-2.11.1\bin>perl mrtg
Usage: mrtg <config-file>

mrtg-2.11.1 is the Multi Router Traffic Grapher.
If you want to know more about this tool, you might want

to read the docs. They came together with mrtg!
Home: http://people.ee.ethz.ch/~oetiker/webtools/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.11.1\bin directory. Type the following command
C:\Documents and Settings\Administrator>cd\
C:\>cd mrtg-2.11.1\bin

C:\mrtg-2.11.1\bin>perl cfgmaker snmpstring@1.1.1.1 --global "workdir:c:\inetpub\wwwroot

\mrtg" --output mrtg.cfg

--base: Get Device Info on snmpstring@1.1.1.1:
--base: Vendor Id: cisco
--base: Populating confcache
--snpo: confcache snmpstring@1.1.1.1: Name Fa0/0--> 1
--snpo: confcache snmpstring@1.1.1.1: Name Se0/0 --> 2
--snpo: confcache snmpstring@1.1.1.1: Name Nu0 --> 3
--snpo: confcache snmpstring@1.1.1.1:

Descr FastEthernet0/0 --> 1
--snpo: confcache snmpstring@1.1.1.1: Descr Serial0/0 --> 2
--snpo: confcache snmpstring@1.1.1.1: Descr Null0 --> 3
--snpo: confcache snmpstring@1.1.1.1: Type 6 --> 1
--snpo: confcache snmpstring@1.1.1.1: Type 22 --> 2
--snpo: confcache snmpstring@1.1.1.1: Type 1 --> 3
--snpo: confcache snmpstring@1.1.1.1:

Ip 203.101.118.154 --> 2
--snpo: confcache snmpstring@1.1.1.1: Ip 1.1.1.1 --> 1
--snpo: confcache snmpstring@1.1.1.1: Eth 00-0f-24-e5-71-80 --> 1
--snpo: confcache snmpstring@1.1.1.1: Eth  --> 2
--snpo: confcache snmpstring@1.1.1.1: Eth  -->

3 (duplicate)
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifMtu
--base: Walking ifAlias
--base: Walking vmVlan
--base: Walking ifSpeed
--base: Writing 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

the cfgmaker manpage
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.
This .cfg file is created in c:\mrtg-2.11.1\bin directory.
And that's a very basic mrtg config file. You can run this and see your results by going into the c:\mrtg-2.11.1\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

C:\mrtg-2.11.1\bin>perl mrtg mrtg.cfg
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup could not read the primary log file fo
r 1.1.1.1_1
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup The backup log file for 1.1.1.1_
1 was invalid as well
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup Can't remove 1.1.1.1_1.old updat
ing log file
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup Can't rename 1.1.1.1_1.log to 20
3.145.132.1_1.old updating log file
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup could not read the primary log file fo
r 1.1.1.1_2
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup The backup log file for 1.1.1.1_
2 was invalid as well
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup Can't remove 1.1.1.1_2.old updat
ing log file
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup Can't rename 1.1.1.1_2.log to 1.1.1.1_2.old updating log file
C:\mrtg-2.11.1\bin>perl mrtg mrtg.cfg
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup Can't remove 1.1.1.1_1.old updat
ing log file
Rateup WARNING: C:/mrtg-2.11.1/bin\rateup Can't remove 1.1.1.1_2.old updat
ing log file
C:\mrtg-2.11.1\bin>perl mrtg mrtg.cfg

These will create a list of web pages at the workdirectory we specifed.i.e c:\Inetpub\wwwroot\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.11.1\bin wperl mrtg --logging=eventlog mrtg.cfg

If you use wperl instead of perl, no console window will show. MRTG is now running in the background. If it runs into problems it will tell you so over the EventLog. To stop MRTG, open the Task Manager and terminate the wperl.exe process. If mrtg has anything to tell you these messages can be found in the event log.

C:\mrtg-2.11.1\bin>cd\

C:\>start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog mrtg.cfg

Now Testing is complete make three folders in mrtg directory with the name gurtr001,gurtr011,gurtr012 for three routers conf files and give following commands.

C:\cd mrtg-2.11.1\bin
C:\mrtg-2.11.1\bin>perl cfgmaker snmpstring@10.203.158.242 --global "workdir:

c:\inetpub\wwwroot\mrtg\gurtr001" --output gurtr001.cfg

C:\mrtg-2.11.1\bin>perl cfgmaker snmpstring@61.246.186.2 --global "workdir:

c:\inetpub\wwwroot\mrtg\gurtr012" --output gurtr012.cfg

C:\mrtg-2.11.1\bin>perl cfgmaker snmpstring@203.145.132.1 --global "workdir:

c:\inetpub\wwwroot\mrtg\gurtr011" --output gurtr011.cfg

These three commands will create three conf files by the name gurtr001.cfg, gurtr011.cfg, gurtr012.cfg in C:\mrtg-2.11.1\bin directory.
Now we need to generate the graphs .for this give following three commands.

start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog gurtr001.cfg
start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog gurtr011.cfg
start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog gurtr012.cfg

These will generate the graphs in mrtg\gurtr001 ,mrtg\gurtr011, mrtg\gurtr012  directories.
Ofcouse we will make run as damenon in all the cfg files whch were created.
C:\mrtg-2.11.1\bin>perl cfgmaker snmpstring@10.203.158.242 --global "workdir:

c:\inetpub\wwwroot\mrtg\gurtr001" --output gurtr001.cfg

--base: Get Device Info on snmpstring@10.203.158.242:
--base: Vendor Id: cisco
--base: Populating confcache
--snpo: confcache snmpstring@10.203.158.242: Name Fa0/0 --> 1
--snpo: confcache snmpstring@10.203.158.242: Name Se0/0 --> 2
--snpo: confcache snmpstring@10.203.158.242: Name Nu0 --> 3
--snpo: confcache snmpstring@10.203.158.242: Name Lo0 --> 4
--snpo: confcache snmpstring@10.203.158.242: Descr FastEthernet0/0 --> 1
--snpo: confcache snmpstring@10.203.158.242: Descr Serial0/0 --> 2
--snpo: confcache snmpstring@10.203.158.242: Descr Null0 --> 3
--snpo: confcache snmpstring@10.203.158.242: Descr Loopback0 --> 4
--snpo: confcache snmpstring@10.203.158.242: Type 6 --> 1
--snpo: confcache snmpstring@10.203.158.242: Type 22 --> 2
--snpo: confcache snmpstring@10.203.158.242: Type 1 --> 3
--snpo: confcache snmpstring@10.203.158.242: Type 24 --> 4
--snpo: confcache snmpstring@10.203.158.242: Ip 10.203.95.17 --> 4
--snpo: confcache snmpstring@10.203.158.242: Ip 10.203.158.242 --> 1
--snpo: confcache snmpstring@10.203.158.242: Ip 192.168.203.70 --> 2
--snpo: confcache snmpstring@10.203.158.242: Eth 00-0f-24-e5-71-00 --> 1
--snpo: confcache snmpstring@10.203.158.242: Eth  --> 2
--snpo: confcache snmpstring@10.203.158.242: Eth  --> 3 (duplicate)
--snpo: confcache snmpstring@10.203.158.242: Eth  --> 4 (duplicate)
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifMtu
--base: Walking ifAlias
--base: Walking vmVlan
--base: Walking ifSpeed
--base: Writing gurtr001.cfg

C:\mrtg-2.11.1\bin>perl cfgmaker snmpstring@61.246.186.2 --global "workdir:

c:\inetpub\wwwroot\mrtg\gurtr012" --output gurtr012.cfg

--base: Get Device Info on snmpstring@61.246.186.2:
--base: Vendor Id: cisco
--base: Populating confcache
--snpo: confcache snmpstring@61.246.186.2: Name Fa0/0 --> 1
--snpo: confcache snmpstring@61.246.186.2: Name Se0/0 --> 2
--snpo: confcache snmpstring@61.246.186.2: Name Fa0/1 --> 3
--snpo: confcache snmpstring@61.246.186.2: Name Se0/1 --> 4
--snpo: confcache snmpstring@61.246.186.2: Name Nu0 --> 5
--snpo: confcache snmpstring@61.246.186.2: Descr FastEthernet0/0 --> 1
--snpo: confcache snmpstring@61.246.186.2: Descr Serial0/0 --> 2
--snpo: confcache snmpstring@61.246.186.2: Descr FastEthernet0/1 --> 3
--snpo: confcache snmpstring@61.246.186.2: Descr Serial0/1 --> 4
--snpo: confcache snmpstring@61.246.186.2: Descr Null0 --> 5
--snpo: confcache snmpstring@61.246.186.2: Type 6 --> 1
--snpo: confcache snmpstring@61.246.186.2: Type 22 --> 2
--snpo: confcache snmpstring@61.246.186.2: Type 6 --> 3 (duplicate)
--snpo: confcache snmpstring@61.246.186.2: Type 22 --> 4 (duplicate)
--snpo: confcache snmpstring@61.246.186.2: Type 1 --> 5
--snpo: confcache snmpstring@61.246.186.2: Ip 61.246.186.2 --> 1
--snpo: confcache snmpstring@61.246.186.2: Ip 203.101.118.38 --> 4
--snpo: confcache snmpstring@61.246.186.2: Eth 00-0b-5f-5d-dc-40 --> 1
--snpo: confcache snmpstring@61.246.186.2: Eth  --> 2
--snpo: confcache snmpstring@61.246.186.2: Eth 00-0b-5f-5d-dc-41 --> 3
--snpo: confcache snmpstring@61.246.186.2: Eth  --> 4 (duplicate)
--snpo: confcache snmpstring@61.246.186.2: Eth  --> 5 (duplicate)
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifMtu
--base: Walking ifAlias
--base: Walking vmVlan
--base: Walking ifSpeed
--base: Writing gurtr012.cfg

Now that graphs are also generated, open notepad paste
start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog gurtr001.cfg
start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog gurtr011.cfg
start /Dc:\mrtg-2.11.1\bin wperl mrtg --logging=eventlog gurtr012.cfg

and save the file as mrtg.bat.
Now put this in the startup ptrogram of all users.
Copy mrtg.bat and go to start –programs—startup---rightclick open all users.—paste the file.

So when we login to this pc these commands will always work.

Now look at the grapths.the new traffic starts from left also traffic is in terms of bytes.so we need to multiply it by 8 to get the actual traffic in bps.
To make above two changes insert
Options[_]: growright, bits

In all the cfg files.actually remove # against         Options [_]: growright, bits
Also you may need to see if bandwidth is correct or not
MaxBytes[203.145.132.1_2]: 256000

Here it is 256Kbytes so 256*8=2048kbps i.e 2mpbs
For 1 MPBS it should be 128000

Now we need to make a html page which has ink to all the pages.

Start-programs-netscape communicator-netscape composer.
Write in it something like
           
Knowurtech Traffic monitoring

1 Mbps ISP1 Internet link


2 Mbps ISP2 Internet Link


2 Mbps Link between knowurtech and knowurheath


Now go to 1 Mbps ISP1 Internet link

Right click ---create link using selected and paste http://10.203.142.5/mrtg/gurtr012/61.246.186.2_4.html.

Where 10.203.142.5 is the ip address of machine running mrtg.
Similarly do for other 3 links..
Then click on preview and save the file as mrtg.html.

Now we need to make it as a default page

Start-programs-administrative tools-internet information services.

Expand default web page.click on mrtg.

Right click mrtg-properties
Go to documents tab
Click enable default document.
Remove anything in the list and click on add type mrtg.html
Now go to thedirectory where mrtg floder is there i.e c:\Inetpub\wwwroot\mrtg and paste mrtg.html file that you made there.
Now you can access this page from anywhere by typing http://10.203.142.5\mrtg.

Now everything is up and running.

Please check the document MRTG partr-2 for more advanced parameters.

If you have any suggestions or want to add more to this article do write us an email articles@knowurtech.com

 

What Next?


If you liked this article, you can share it with others using the following link:


Related Content :