NAME 

mrtg-reference - MRTG 2.14.5 configuration reference

OVERVIEW 

The runtime behaviour of MRTG is governed by a configuration file. Run-of- ther-mill configuration files can be generated with cfgmaker. (Check cfgmaker). But for more elaborate configurations some hand-tuning is required.

This document describes all the configuration options understood by the mrtg software.

SYNTAX 

MRTG configuration file syntax follows some simple rules:
*
Keywords must start at the beginning of a line.
*
Lines which follow a keyword line which start with a blank are appended to the keyword line
*
Empty Lines are ignored
*
Lines starting with a # sign are comments.
*
You can add other files into the configuration file using

Include: file

Example:

 Include: base-options.inc

If included files are specified with relative paths, both the current working directory and the directory containing the main config file will be searched for the files.

GLOBAL KEYWORDS 

WorkDir 

WorkDir specifies where the logfiles and the webpages should be created.

Example:

 WorkDir: /usr/tardis/pub/www/stats/mrtg

OPTIONAL GLOBAL KEYWORDS 

HtmlDir 

HtmlDir specifies the directory where the html (or shtml, but we'll get on to those later) lives.

NOTE: Workdir overrides the settings for htmldir, imagedir and logdir.

Example:

 Htmldir: /www/mrtg/

ImageDir 

ImageDir specifies the directory where the images live. They should be under the html directory.

Example:

 Imagedir: /www/mrtg/images

LogDir 

LogDir specifies the directory where the logs are stored. This need not be under htmldir directive.

Example:

 Logdir: /www/mrtg/logs

Forks (UNIX only)

With system that supports fork (UNIX for example), mrtg can fork itself into multiple instances while it is acquiring data via snmp.

For situations with high latency or a great number of devices this will speed things up considerably. It will not make things faster, though, if you query a single switch sitting next door.

As far as I know NT can not fork so this option is not available on NT.

Example:

 Forks: 4

EnableIPv6 

When set to yes, IPv6 support is enabled if the required libraries are present (see the mrtg-ipv6 manpage). When IPv6 is enabled, mrtg can talk to routers using SNMP over IPv6 and targets may be specified by their numeric IPv6 addresses as well as by hostname or IPv4 address.

If IPv6 is enabled and the target is a hostname, mrtg will try to resolve the hostname to an IPv6 address and, if this fails, to an IPv4 address. Note that mrtg will only use IPv4 if you specify an IPv4 address or a hostname with no corresponding IPv6 address; it will not fall back to IPv4 if it simply fails to communicate with the target using IPv6. This is by design.

Note that many routers do not currently support SNMP over IPv6. Use the IPv4Only per target option for these routers.

IPv6 is disabled by default.

Example:

 EnableIPv6: Yes

EnableSnmpV3 

When set to yes, uses the Net::SNMP module instead of the SNMP_SESSION module for generating snmp queries. This allows the use of SNMPv3 if other snmpv3 parameters are set.

SNMPv3 is disabled by default.

Example:

 EnableSnmpV3: yes

Refresh 

How many seconds apart should the browser (Netscape) be instructed to reload the page? If this is not defined, the default is 300 seconds (5 minutes).

Example:

 Refresh: 600

Interval 

How often do you call mrtg? The default is 5 minutes. If you call it less often, you should specify it here. This does two things:
*
The generated HTML page contains the right information about the calling interval ...
*
A META header in the generated HTML page will instruct caches about the time-to-live of this page .....

In this example, we tell mrtg that we will be calling it every 10 minutes. If you are calling mrtg every 5 minutes, you can leave this line commented out.

Example:

 Interval: 10

Note that unless you are using rrdtool you can not set Interval to less than 5 minutes. If you are using rrdtool you can set interval down to 1 minute. Note though, setting the Interval for an rrdtool/mrtg setup will influence the initial creation of the database. If you change the interval later, all existing databases will remain at the resolution they were initially created with.

MaxAge 

MRTG relies heavily on the real time clock of your computer. If the time is set to a wrong value, especially if it is advanced far into the future, this will cause mrtg to expire lots of supposedly old data from the log files.

To prevent this, you can add a 'reasonability' check by specifying a maximum age for log files. If a file seems to be older, mrtg will not touch it but complain instead, giving you a chance to investigate the cause.

Example:

 MaxAge: 7200

The example above will make mrtg refuse to update log files older than 2 hours (7200 seconds).

WriteExpires 

With this switch mrtg will generate .meta files for CERN and Apache servers which contain Expiration tags for the html and gif files. The *.meta files will be created in the same directory as the other files, so you will have to set ``MetaDir .'' and ``MetaFiles on'' in your apache.conf or .htaccess file for this to work

NOTE: If you are running Apache-1.2 or later, you can use the mod_expire to achieve the same effect ... see the file htaccess.txt

Example:

 WriteExpires: Yes

NoMib2 

Normally we ask the SNMP device for 'sysUptime' and 'sysName' properties. Some do not have these. If you want to avoid getting complaints from mrtg about these missing properties, specify the nomib2 option.

An example of agents which do not implement base mib2 attributes are Computer Associates - Unicenter TNG Agents. CA relies on using the base OS SNMP agent in addition to its own agents to supplement the management of a system.

Example:

 NoMib2: Yes

SingleRequest 

Some SNMP implementations can not deal with requests asking for multiple snmp variables in one go. Set this in your cfg file to force mrtg to only ask for one variable per request.

Examples

 SingleRequest: Yes

SnmpOptions 

Apart from the per target timeout options, you can also configure the behaviour of the snmpget process on a more profound level. SnmpOptions accepts a hash of options. The following options are currently supported:
 timeout                   => $default_timeout,
 retries                   => $default_retries,
 backoff                   => $default_backoff,
 default_max_repetitions   => $max_repetitions,
 use_16bit_request_ids     => 1,
 lenient_source_port_matching => 0,
 lenient_source_address_matching => 1

The values behind the options indicate the current default value. Note that these settings OVERRIDE the per target timeout settings.

A per-target SnmpOptions[] keyword will override the global settings. That keyword is primarily for SNMPv3.

The 16bit request ids are the only way to query the broken SNMP implementation of SMC Barricade routers.

Example:

 SnmpOptions: retries => 2, only_ip_address_matching => 0

Note that AS/400 snmp seems to be broken in a way which prevents mrtg from working with it unless

 SnmpOptions: lenient_source_port_matching => 1

is set.

IconDir 

If you want to keep the mrtg icons in someplace other than the working (or imagedir) directory, use the IconDir variable for defining the url of the icons directory.

Example:

 IconDir: /mrtgicons/

LoadMIBs 

Load the MIB file(s) specified and make its OIDs available as symbolic names. For better efficiancy, a cache of MIBs is maintained in the WorkDir.

Example:

 LoadMIBs: /dept/net/mibs/netapp.mib,/usr/local/lib/ft100m.mib

Language 

Switch output format to the selected Language (Check the translate directory to see which languages are supported at the moment. In this directory you can also find instructions on how to create new translations).

Currently the following laguages are supported:

big5 brazilian bulgarian catalan chinese croatian czech danish dutch eucjp french galician gb gb2312 german greek hungarian icelandic indonesia iso2022jp italian korean lithuanian malay norwegian polish portuguese romanian russian russian1251 serbian slovak slovenian spanish swedish turkish ukrainian

Example:

 Language: danish

LogFormat 

Setting LogFormat to 'rrdtool' in your mrtg.cfg file enables rrdtool mode. In rrdtool mode, mrtg relies on rrdtool to do its logging. See mrtg-rrd.

Example:

 LogFormat: rrdtool

LibAdd 

If you are using rrdtool mode and your rrdtool Perl module (RRDs.pm) is not installed in a location where perl can find it on its own, you can use LibAdd to supply an appropriate path.

Example:

 LibAdd: /usr/local/rrdtool/lib/perl/

PathAdd 

If the rrdtool executable can not be found in the normal "PATH", you can use this keyword to add a suitable directory to your path.

Example:

 PathAdd: /usr/local/rrdtool/bin/

RunAsDaemon 

The RunAsDaemon keyword enables daemon mode operation. The purpose of daemon mode is that MRTG is launched once and not repeatedly (as it is with cron). This behavior saves computing resourses as loading and parsing of configuration files happens only once.

Using daemon mode MRTG itself is responible for timing the measurement intervals. Therfore its important to set the Interval keyword to an apropiate value.

Note that when using daemon mode MRTG should no longer be started from cron as each new process runs forever. Instead MRTG should be started from the command prompt or by a system startup script.

If you want mrtg to run under a particular user and group (it is not recomended to run MRTG as root) then you can use the --user=user_name and --group=group_name options on the mrtg commandline.

 mrtg --user=mrtg_user --group=mrtg_group mrtg.cfg

Also note that in daemon mode restarting the process is required in order to activate changes in the config file.

Under UNIX, the Daemon switch causes mrtg to fork into background after checking its config file. On Windows NT the MRTG process will detach from the console, but because the NT/2000 shell waits for its children you have to use this special start sequence when you launch the program:

 start /b perl mrtg mrtg.cfg

You may have to add path information equal to what you add when you run mrtg from the commandline.

Example

 RunAsDaemon: Yes
 Interval:    5

This makes MRTG run as a daemon beginning data collection every 5 minutes

If you are daemontools and still want to run mrtg as a daemon you can additionally specify

 NoDetach:     Yes

this will make mrtg run but without detaching it from the terminal.