MRTG Implementation Manual
Table of Contents
 

 
 

3. Configuring MRTG tasks
 

3.1 Building the “.cfg” configuration files

A .cfg file is required for each monitored host or a global .cfg file can be used for all monitored hosts, but the flexibility will decrease. 

A .cfg file defines the SNMP OIDs for each entity that you intend to monitor from the destination host. MRTG parses the associated .cfg file and collects the SMNP values for all OIDs defined in the .cg file. 

To build a .cfg file run the “CFGMAKER” script, which resides in the \mrtg\bin\ directory. This script scans a host for the network-interfaces only and constructs the .cfg file 

The syntax is: 

perl cfgmaker [options] [community@]router1 [[options] [community@]router2 ... ]

The CFGMAKER options are:  


  

--ifref=nr        interface references by Interface Number (default) 

--ifref=ip                         ... by Ip Address 

--ifref=eth                        ... by Ethernet Number 

--ifref=descr                      ... by Interface Description 

--ifref=name                       ... by Interface Name 

--ifref=type                       ... by Interface Type 

--ifdesc=nr       interface description uses Interface Number (default) 

--ifdesc=ip                        ... uses Ip Address 

--ifdesc=eth                       ... uses Ethernet Number 

--ifdesc=descr                     ... uses Interface Description 

--ifdesc=name                      ... uses Interface Name 

--ifdesc=alias                     ... uses Interface Alias 

--ifdesc=type                      ... uses Interface Type 

--if-filter=f     Test every interface against filter f to decide wether  or not to include that interface into the collection. Currently f is being evaluated as a Perl expression and it's truth value is used to reject or accept the interface.  (Experimental, under development, might change) 

--if-template=templatefile    Replace the normal target entries for the interfaces with an entry as specified by the contents in the file templatefile.  The file is supposed to contain Perl code to be executed to generate the lines for the target in the configuration file.(Experimental, under development, might change) 

--host-template=templatefile      In addition to creating targets for a host's interfacesdo also create targets for the host itself as specified  by the contents in the file templatefile.  The file is  supposed to contain Perl code to be executed to generate the lines for the host related targets (such as CPU,   ping response time measurements etc.) in the config-                       uration file. (Experimental, under development, might change) 

--global "x: a"   add global config entries 

--no-down         do not look at admin or opr status of interfaces 

--show-op-down    show interfaces which are operatively down 

--descint         describe interface instead of just 'Traffic Analysis for' 

--subdirs=format give each router its own subdirectory, naming each per  "format", in which HOSTNAME and SNMPNAME will be  replaced by the values of those items -- for instance, 

--subdirs=HOSTNAME or --subdirs="HOSTNAME (SNMPNAME)" 

--noreversedns    do not reverse lookup ip numbers 

--community=cmty  Set the default community string to "cmty" instead of  "public". 

--snmp-options=:[<port>][:[<tmout>][:[<retr>][:[<backoff>][:<ver>]]]]    Specify default SNMP options to be appended to all  routers following.  Individual fields can be empty.  Routers following might override some or all of the  options given to --snmp-options. 

--dns-domain=domain Specifies a domain to append to the name of all  routers following. 

--nointerfaces    Don't do generate any configuration lines for interfaces,  skip the step of gathering interface information and  don't run any interface template code. 

--interfaces     Generate configuration lines for interfaces (this is thedefault).  The main purpose of this option is to negate  an --nointerfaces appearing earlier on the command line. 

--help            brief help message 

--man             full documentation 

--version         print the version of cfgmaker 

--output=file     output filename default is STDOUT

MRTG will interrogate the target host, will extract the SNMP OIDs for all network interfaces and construct the .cfg file for that specific host. 

Once the .cfg file has bee constructed, the following folder options must be added to the file: 
 
  


  

Workdir  // specifies the working directory 
Syntax: Workdir: working-folder-path

Htmldir  // specifies where the html files will be copied
Syntax: Htmldir: html-folder-path

Imagedir // specifies where the png will be copied
Syntax: Imagedir: image-folder-path

Logdir  // specifies where the log files will be copied
Syntax: Logdir: html-folder-path

Icondir  // specifies where the MRTG icons are
Syntax: Icondir: html-folder-path

Example: 

Workdir: c:\inetpub\10.0.0.1\ 
Htmldir: c:\inetpub\10.0.0.1\ 
Imagedir: c:\inetpub\10.0.0.1\ 
Logdir: c:\inetpub\10.0.0.1\ 
Icondir: d:\mrtg-2.9.21\images\ 

The PNG graphs are growing by default from right to left and are represented in Bytes/sec. 
To change this representation to Bits/sec and get the raph growing from left to right, just add the following option to the .cfg file: 

Options[_]: growright, bits
 

CFGMAKER Example

Here is a CFGMAKER usage example and the resulted .cfg file: 
  


  

D:\mrtg\bin\> perl cfgmaker --output d:\mrtg\branch.cfg --show-op-down --ifref=name --ifdesc=name --descint public@10.1.1.10

This command will interrogate the 10.1.1.10 host and parse its network interfaces. 
The result is the following .cfg file: 

# Created by 
perl cfgmaker --output d:\mrtg\branch.cfg --show-op-down --ifref=name --ifdesc=name --descint public@10.1.1.10
 

Workdir: d:\inetpub\wwwroot\
 Htmldir: d:\inetpub\wwwroot\ \
Imagedir: d:\inetpub\wwwroot\
Logdir: d:\inetpub\wwwroot\
Icondir: /images/

Refresh: 300
RunAsDaemon: Yes
Interval: 5

#  to get bits instead of bytes and graphs growing to the right
Options[_]: growright, bits
 

######################################################################
# System: Router-10.1.1.10
# Description: Cisco Internetwork Operating System Software 
#          IOS (tm) 3600 Software (C3640-JS-M), Version 12.1(3a)T1,  RELEASE SOFTWARE (fc1)
#          Copyright (c) 1986-2000 by cisco Systems, Inc.
#          Compiled Sat 29-Jul-00 11:48 by ccai
# Contact: 
# Location: 
######################################################################
 

Interface 1 >> Descr: 'BRI0/0' | Name: '' | Ip: '' | Eth: '' ###
The following interface is commented out because:
* --ifref=name is not unique for this interface

Target[10.1.254.8_1]: 1:public@10.1.254.8:
SetEnv[10.1.254.8_1]: MRTG_INT_IP="" MRTG_INT_DESCR="BRI0/0"
 MaxBytes[10.1.254.8_1]: 2000
 Title[10.1.254.8_1]: 1 
 PageTop[10.1.254.8_1]: <H1>1 </H1>
  <TABLE>
    <TR><TD>System:</TD>     <TD> in </TD></TR>
    <TR><TD>Maintainer:</TD> <TD></TD></TR>
    <TR><TD>Description:</TD><TD>BRI0/0 ISDN BACK-UP TO F500_2202 and F501_2206 </TD></TR>
    <TR><TD>ifType:</TD>     <TD>Link Access Protocol D (LAPD) (77)</TD></TR>
    <TR><TD>ifName:</TD>     <TD></TD></TR>
    <TR><TD>Max Speed:</TD>  <TD>2000.0 Bytes/s</TD></TR>
  </TABLE>
 

### Interface 2 >> Descr: 'FastEthernet0/0' | Name: 'Fa0/0' | Ip: '' | Eth: '' ###

Target[10.1.254.8_Fa0_0]: #Fa0/0:public@10.1.254.8:
SetEnv[10.1.254.8_Fa0_0]: MRTG_INT_IP="" MRTG_INT_DESCR="FastEthernet0/0"
MaxBytes[10.1.254.8_Fa0_0]: 12500000 
Title[10.1.254.8_Fa0_0]: #Fa0/0 
PageTop[10.1.254.8_Fa0_0]: <H1>#Fa0/0 -- F80CRS</H1>
 <TABLE>
   <TR><TD>System:</TD>     <TD>F80CRS in </TD></TR>
   <TR><TD>Maintainer:</TD> <TD></TD></TR>
   <TR><TD>Description:</TD><TD>FastEthernet0/0  </TD></TR>
   <TR><TD>ifType:</TD>     <TD>ethernetCsmacd (6)</TD></TR>
   <TR><TD>ifName:</TD>     <TD>Fa0/0</TD></TR>
   <TR><TD>Max Speed:</TD>  <TD>12.5 MBytes/s</TD></TR>
 </TABLE>
 


For more information on CFGMAKER options go to http://people.ee.ethz.ch/~oetiker/webtools/mrtg/cfgmaker.html
 

3.2 Building the “index.html” files

The HTML index files are being built based on the previously created .cfg file. The role of the index.html file is to put together the html links to the individual network interfaces that are being monitored. 

The index file is created by INDEXMAKER script. 
The syntax is: 
 

perl indexmaker [options] [.cfg file]

The options are: 
 
  


  

--output=filename   set output filename (default: stdout) 
 --filter title=~regexp  select targets by matching regexp against titles 
 --filter pagetop=~regexp  select targets by matching regexp against pagetop 
 --filter name=~regexp  select targets by matchin regexp against name 
 --title=text        set title of generated index file 
 --bodyopt=text      set body tag options 
 --headlevel=number  use <Hnumber> at top of page (default: 1) 
 --pagetop=text      insert this text between <BODY> and <H1>...</H1> 
 --pageend=text      insert this text after the main body 
 --pagetopend=text   use this text for pagetop or pageend if undefined 
 --legend            add the Mrtg legend at the end of the page (default: add) 
 --columns=number    show graphs in a table with x columns (default: 2) 
 --compact           try to make a vertically more compact page 
 --optlog            log the used command line in the page (default: log) 
 --sort=title        sort graphs by title 
 --sort=name         sort graphs by their name 
 --sort=descr        sort graphs by their description 
 --sort=original     leave as is (default) 
 --enumerate         add a sequence number to the title of each graph 
 --picfirst          place pictures before text (default: text first) 
 --width=number      set width of graphs (default: not set) 
 --height=number
 --sidebyside      place text / pictures side by side (default: above/below) 
 --bold              use bold text (default: bold) 
 --clicktext         make the text link to the inner page (like the image) 
 --show=day          pick which graph to show in the index (default) 
 --show=week
 --show=month
 --show=year
 --show=none
 --section=h1        h1 tag from pagetop as section heading (default) 
 --section=title     title as section headings for graphs 
 --section=name      graph name as section heading 
 --section=descr     graph description as section heading 
 --section=portname  port name entry in pagetop as section heading 
 --sectionhost       Try to prepend the host to the section heading if missing 
 --rrdviewer=path    path to rrdviewer (default: /cgi-bin/14all.cgi) 
 --prefix=path       path from the location of the index.html to the graphs 
 --autoprefix        try to set prefix automatically 
 --<opt>-file=file   read string argument for option <opt> from file
IndexMaker will create an html file, which has to be copied  (recommended as index.html) into the folder where the html/image/log files are stored. 

Example: 

perl indexmaker --output d:\mrtg\10.1.1.10.index --compact  d:\mrtg\10.1.1.10.cfg
 

3.3 Configuration summary

After proceeding with the previous steps, the current MRTG status should be: 

a. Perl, MRTG and the WebServer are installed. 
b. Configuration files (.cfg) for all monitored hosts have been generated using CFGMAKER. These files will be guiding the MRTG process in the SNMP acquisition. 
c.  HTML index files for all hosts are generated and copied in the folders where the image/log/html files are. Mostly recommended is to name it “index.html” and use a folder for each monitored host to store its own related data. 

d. Next step: Get the MRTG process running and visualize the variation graphs. 
 
 

<Next Chapter>