Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 722d7fe08e521069eaa66d51f59d0ed2 > files > 469

mrtg-2.9.17-4mdk.i586.rpm

<HTML>
<HEAD>
<TITLE>doc/cfgmaker</TITLE>
<LINK REV="made" HREF="mailto:karrer@iis.ee.ethz.ch">
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#990200" VLINK="#006342"><P><IMG SRC="mrtg-l.png"><IMG SRC="mrtg-m.png"><IMG SRC="mrtg-r.gif"></P>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<!--

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
	<LI><A HREF="#options">OPTIONS</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<UL>

		<LI><A HREF="#configuration">Configuration</A></LI>
	</UL>

	<LI><A HREF="#details on filters">DETAILS ON FILTERS</A></LI>
	<UL>

		<LI><A HREF="#predefined filter variables">Predefined Filter Variables</A></LI>
		<LI><A HREF="#examples on filters">Examples on Filters</A></LI>
	</UL>

	<LI><A HREF="#details on templates">DETAILS ON TEMPLATES</A></LI>
	<UL>

		<LI><A HREF="#writable template variables">Writable Template Variables</A></LI>
		<LI><A HREF="#predefined template variables">Predefined Template Variables</A></LI>
		<UL>

			<LI><A HREF="#host and system variables">Host and System Variables</A></LI>
			<LI><A HREF="#interface target related variables">Interface Target Related Variables</A></LI>
			<LI><A HREF="#interface network configuration variables">Interface Network Configuration Variables</A></LI>
			<LI><A HREF="#interface name, description and alias variables">Interface Name, Description and Alias Variables</A></LI>
		</UL>

		<LI><A HREF="#help functions for templates">Help Functions for Templates</A></LI>
		<LI><A HREF="#example template files">Example Template Files</A></LI>
		<UL>

			<LI><A HREF="#template example 1: eliminating rejected targets from appearing">Template Example 1: Eliminating Rejected Targets From Appearing</A></LI>
			<LI><A HREF="#template example 2: simplier version of example 1">Template Example 2: Simplier Version of Example 1</A></LI>
		</UL>

	</UL>

	<LI><A HREF="#examples">EXAMPLES</A></LI>
	<LI><A HREF="#see also">SEE ALSO</A></LI>
	<LI><A HREF="#author">AUTHOR</A></LI>
	<LI><A HREF="#license">LICENSE</A></LI>
	<LI><A HREF="#copyright">COPYRIGHT</A></LI>
</UL>
-->
<!-- INDEX END -->

<P>
<H1><A NAME="name">NAME</A></H1>
<P>cfgmaker - Creates mrtg.cfg files (for mrtg-2.9.17)</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<P>cfgmaker [options] [community@]router [[options] [community@]router ...]</P>
<P>
<HR>
<H1><A NAME="options">OPTIONS</A></H1>
<PRE>
 --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</PRE>
<PRE>
 --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</PRE>
<PRE>
 --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)</PRE>
<PRE>
 --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)
</PRE>
<PRE>

 --host-template=templatefile
                   In addition to creating targets for a host's interfaces 
                   do 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)</PRE>
<PRE>

 --global &quot;x: a&quot;   add global config entries</PRE>
<PRE>
 --no-down         do not look at admin or opr status of interfaces</PRE>
<PRE>
 --show-op-down    show interfaces which are operatively down</PRE>
<PRE>
 --descint         describe interface instead of just 'Traffic Analysis for'</PRE>
<PRE>
 --subdirs=format  give each router its own subdirectory, naming each per 
                   &quot;format&quot;, in which HOSTNAME and SNMPNAME will be 
                   replaced by the values of those items -- for instance,  
                   --subdirs=HOSTNAME or --subdirs=&quot;HOSTNAME (SNMPNAME)&quot;</PRE>
<PRE>
 --noreversedns    do not reverse lookup ip numbers</PRE>
<PRE>
 --community=cmty  Set the default community string to &quot;cmty&quot; instead of
                   &quot;public&quot;.</PRE>
<PRE>
 --snmp-options=:[&lt;port&gt;][:[&lt;tmout&gt;][:[&lt;retr&gt;][:[&lt;backoff&gt;][:&lt;ver&gt;]]]]</PRE>
<PRE>
                   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.</PRE>
<PRE>
 --dns-domain=domain
                   Specifies a domain to append to the name of all
                   routers following.</PRE>
<PRE>
 --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.</PRE>
<PRE>
 --interfaces      Generate configuration lines for interfaces (this is the
                   default).  The main purpose of this option is to negate
                   an --nointerfaces appearing earlier on the command line.</PRE>
<PRE>
 --help            brief help message
 --man             full documentation
 --version         print the version of cfgmaker</PRE>
<PRE>
 --output=file     output filename default is STDOUT</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P><STRONG>Cfgmaker</STRONG> creates MRTG configuration files based on information
pulled from a router or another SNMP manageable device.</P>
<P>[<EM>community</EM><STRONG>@</STRONG>]<EM>router</EM></P>
<P><EM>Community</EM> is the community name of the device you want to create a
configuration for. If not specified, it defaults to '<STRONG>public</STRONG>'; you might
want to try this first if you do not know the community name of a
device. If you are using the wrong comunity name you will get no
response from the device.</P>
<P><EM>Router</EM> is the DNS name or the IP number of an SNMP-managable device.           
Following the name you can specify 6 further options separated by                 
colons.  The full syntax looks like this:</P>
<P><STRONG>router</STRONG>[:[<STRONG>prt</STRONG>][:[<STRONG>tmout</STRONG>][:[<STRONG>retr</STRONG>][:[<STRONG>backoff</STRONG>][:<STRONG>vers</STRONG>]]]]]</P>
<P>Of special interest may be the last parameter, <STRONG>vers</STRONG>.  If you set this to
'2' then your device will be queried with SNMP version 2 requests. This
allows to poll the 64 bit traffic counters in the device and will thus work
much better with fast interfaces (no more counter overrun).  Note that the
order in which the routers are specified on the command line do matter as
the same order is used when the configuration file is generated.  The first
specified router has it's configuration lines genrated first, followed by
the lines belonging to the next router and so on.</P>
<P>
<H2><A NAME="configuration">Configuration</A></H2>
<P>Except for the <STRONG>--output</STRONG> and <STRONG>--global</STRONG> options, all options affect
only the routers following them on the command line.  If an option
specified earlier on the command line reappears later on the command
line with another value, the new value overrides the old value as far as
remaining routers are concerned.  This way options might be tailored for
groups of routers or for individual routers.</P>
<P>See <STRONG>--output</STRONG> and <STRONG>--global</STRONG> for how their behaviour is affected by
where or how many times they appear on the command line.</P>
<P>See the <STRONG>Examples</STRONG> below on how to set an option differently for
multiple routers.</P>
<DL>
<DT><STRONG><A NAME="item_%2D%2Dhelp"><STRONG>--help</STRONG></A></STRONG><BR>
<DD>
Print a brief help message and exit.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dman"><STRONG>--man</STRONG></A></STRONG><BR>
<DD>
Prints the manual page and exits.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dversion"><STRONG>--version</STRONG></A></STRONG><BR>
<DD>
Print the version of cfgmaker.  This should match the version of MRTG
for which config files are being created.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Difref_nr%7Cip%7Ceth%7Cdescr%7Cname"><STRONG>--ifref</STRONG> <STRONG>nr</STRONG>|<STRONG>ip</STRONG>|<STRONG>eth</STRONG>|<STRONG>descr</STRONG>|<STRONG>name</STRONG></A></STRONG><BR>
<DD>
Select the interface identification method.  Default is <STRONG>nr</STRONG> which
identifies the router interfaces by their number.  Unfortunately the
interface numbering scheme in an SNMP tree can change. Some routers
change their numbering when new interfaces are added, others change
thier numbering every full moon just for fun.
<P>To work around this sad problem MRTG can identify interfaces by 4
other properties. None of these works for all interfaces, but you
should be able to find one which does fine for you. Note that
especially ethernet addrsses can be problematic as some routers have
the same ethernet address on most of their interface cards.</P>
<P>Select <STRONG>ip</STRONG> to identify the interface by its IP number. Use <STRONG>eth</STRONG> to
use the ethernet address for identification. Use <STRONG>descr</STRONG> to use
the Interface description. Or use <STRONG>name</STRONG> to use the Interface name.</P>
<P>If your chosen method does not allow unique interface identification on
the device you are querying, <STRONG>cfgmaker</STRONG> will tell you about it.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Difdesc_nr%7Cip%7Ceth%7Cdescr%7Cname%7Ctype%7"><STRONG>--ifdesc</STRONG> <STRONG>nr</STRONG>|<STRONG>ip</STRONG>|<STRONG>eth</STRONG>|<STRONG>descr</STRONG>|<STRONG>name</STRONG>|<STRONG>type</STRONG>|<STRONG>alias</STRONG></A></STRONG><BR>
<DD>
Select what to use as the description of the interface.  The description
appears in the <CODE>Title[]</CODE> property for the target as well as the text header
in the HTML code defined in the target's <CODE>PageTop[]</CODE>.  Default is to use
<STRONG>nr</STRONG> which is just the interface number which isn't always useful
to the viewer of the graphs.
<P>There are 6 other properties which could be used.  Use <STRONG>ip</STRONG> if you want
to use the interface's IP-address.  Use <STRONG>eth</STRONG> if you want to use the
interface's ethernet address.  If you want a better description, you can
use either <STRONG>descr</STRONG>, <STRONG>name</STRONG> or <STRONG>alias</STRONG>.  Exactly what each of these do
varies between different equipment so you might need to experiment.  For
instance, for a serial interface on a Cisco router running IOS using <STRONG>name</STRONG>
might result in <CODE>&quot;S0&quot;</CODE> being the interface description , <STRONG>descr</STRONG> might result
in <CODE>&quot;Serial0&quot;</CODE> and <STRONG>alias</STRONG> might result in <CODE>&quot;Link to HQ&quot;</CODE> (provided that is
what is used as the interface's <CODE>description</CODE> in the router's configuration).</P>
<P>Finally, if you want to describe the interface by it's Btype
(i.e <CODE>&quot;ethernetCSMA&quot;</CODE>, <CODE>&quot;propPointtoPoint&quot;</CODE> etc) you can use <STRONG>type</STRONG>.  This is
roughly equivalent to the <STRONG>--descint</STRONG> option above.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dif%2Dfilter_%27filter%2Dexpression%27"><STRONG>--if-filter</STRONG> '<STRONG>filter-expression</STRONG>'</A></STRONG><BR>
<DD>
First of all, this is under some developement and is experimental.
<P>Use this if you want to have better control over what interfaces gets
included into the configuration.  The <STRONG>filter-expression</STRONG> is evaluated
as a piece of Perl code and is expected
to return a truth value.  If true, include the interface and if false,
exclude the interface.</P>
<P>For a further discussion on how these filters work, see the section
<A HREF="#details on filters">DETAILS ON FILTERS</A> below.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dif%2Dtemplate_template%2Dfile"><STRONG>--if-template</STRONG> <STRONG>template-file</STRONG></A></STRONG><BR>
<DD>
First of all, this is under some development and is experimental.
<P>Use this if you want to control what the line for each target should look
like in the configuration file.  The contents of the file <STRONG>template-file</STRONG>
will be evaluated as a Perl program which generates the lines using certain
variables for input and output.</P>
<P>For a further discussion on how these templates work, see the section
<A HREF="#details on templates">DETAILS ON TEMPLATES</A> below.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dhost%2Dtemplate_template%2Dfile"><STRONG>--host-template</STRONG> <STRONG>template-file</STRONG></A></STRONG><BR>
<DD>
First of all, this is under some development and is experimental.
<P>Use this if you want to have some extra targets related to the host itself
such as CPU utilization, ping response time to the host, number of busy
modems etc.  The contents of the file <STRONG>template-file</STRONG> will be evaluated
once per host as a Perl program which generates the lines using certain
variables for input and output.</P>
<P>For a further discussion on how these templates work, see the section
<A HREF="#details on templates">DETAILS ON TEMPLATES</A> below.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dcommunity_community%2Dstring"><STRONG>--community</STRONG> <STRONG>community-string</STRONG></A></STRONG><BR>
<DD>
Use this to set the community for the routers following on the command
line to <STRONG>community-string</STRONG>.  Individual routers might overrride this
community string by using the syntax <STRONG>community</STRONG><STRONG>@</STRONG><STRONG>router</STRONG>.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dsnmp%2Doptions_%3A%5Bport%5D%5B%3A%5Btimeout"><STRONG>--snmp-options</STRONG>  :[<STRONG>port</STRONG>][:[<STRONG>timeout</STRONG>][:[<STRONG>retries</STRONG>][:[<STRONG>backoff</STRONG>][:<STRONG>version</STRONG>]]]]</A></STRONG><BR>
<DD>
Use this to set the default SNMP options for all routers following on the
command line.  Individual values might be omitted as well as trailing
colons.  Note that routers might override individual (or all) values
specified by <STRONG>--snmp-options</STRONG> by using the syntax
<P><STRONG>router</STRONG>[:[<STRONG>port</STRONG>][:[<STRONG>timeout</STRONG>][:[<STRONG>retries</STRONG>][:[<STRONG>backoff</STRONG>][:<STRONG>version</STRONG>]]]]]</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dglobal_%22bla%3A_abc%22"><STRONG>--global</STRONG> <STRONG>``</STRONG><EM>bla: abc</EM><STRONG>''</STRONG></A></STRONG><BR>
<DD>
Use this to add global options to the generated config file. 
You can call <STRONG>--global</STRONG> several times to add multiple options.
The line will appear in the configuration just before the config for
the next router appearing on the command line.
<PRE>
 --global &quot;workdir: /home/mrtg&quot;</PRE>
<P>If you want some default Options you might want to put</P>
<PRE>
 --global &quot;options[_]: growright,bits&quot;</PRE>
<P>Specifying <STRONG>--global</STRONG> after the last router on the command line will
create a line in the configuration file which will appear after all the
routers.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dnoreversedns"><STRONG>--noreversedns</STRONG></A></STRONG><BR>
<DD>
Do not try to reverse lookup IP numbers ... a must for DNS free environments.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dno%2Ddown"><STRONG>--no-down</STRONG></A></STRONG><BR>
<DD>
Normally cfgmaker will not include interfaces which are marked
anything but administratively and operationally UP. With this
switch you get them all.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dshow%2Dop%2Ddown"><STRONG>--show-op-down</STRONG></A></STRONG><BR>
<DD>
Include interfaces which are operatively down.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dsubdirs_format"><STRONG>--subdirs</STRONG> <EM>format</EM></A></STRONG><BR>
<DD>
Give each router its own subdirectory for the HTML and graphics (or
.rrd) files.  The directory name is the given <EM>format</EM> string with a
couple of pattern replacements.  The string ``HOSTNAME'' will be
replaced by the hostname of the router (however you specified it on
the <STRONG>cfgmaker</STRONG> commandline -- it may be an actual hostname or just an
IP address), and ``SNMPNAME'' will be replaced with the device's idea of
its own name (the same name that appears on the right side of the
``Title'' lines).  For instance, a call like:
<PRE>
 cfgmaker --subdirs=HOSTNAME__SNMPNAME public@10.10.0.18</PRE>
<P>would result in the generation of lines looking something like:</P>
<PRE>
 Directory[10.10.0.18_1]: 10.10.0.18__fp2200-bothrip-1.3</PRE>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Doutput_file"><STRONG>--output</STRONG> <EM>file</EM></A></STRONG><BR>
<DD>
Write the output from <STRONG>cfgmaker</STRONG> into the file <EM>file</EM>. The default
is to use <CODE>STDOUT</CODE>. <STRONG>--output</STRONG> is expected to appear only once on the
command line. If used multiple times, the file specified by the last
<STRONG>--output</STRONG> will be used.
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dnointerfaces"><STRONG>--nointerfaces</STRONG></A></STRONG><BR>
<DD>
Don't generate configuration lines for interfaces.
<P>This makes cfgmaker skip all steps related to interfaces which means
it will not do any polling of the router to retrieve interface
information which speeds up the execution of cfgmaker and it will
neither run any interface templates.</P>
<P></P>
<DT><STRONG><A NAME="item_%2D%2Dinterfaces"><STRONG>--interfaces</STRONG></A></STRONG><BR>
<DD>
This makes cfgmaker generate configuration lines for interfaces (the
default behaviour).
<P>The main usage of this option is to negate an --nointerfaces appearing
earlier on the command line.</P>
<P></P></DL>
<P>
<HR>
<H1><A NAME="details on filters">DETAILS ON FILTERS</A></H1>
<P>The purpose of the filters is to decide which interfaces to accept and
which interfaces to reject.  This decision is done for each interface by
evaluating the filter expression as a piece of Perl code and investigating
the result of the evaluation.  If true, accept the interface otherwise
reject it.</P>
<P>When working with filters, remember that Perl has it's own idea of what truth
and false is.  The empty string ``'' and the string ``0'' are false, all other
strings are true.  This further imples that any integer value of 0 is
false as well as any undef value.  It also implies that all references
are considered true.</P>
<P>As the filter is evaluated as a Perl expression, several useful constructs
in Perl are worth mentioning:</P>
<P>Expressions might be grouped by using parentheses ``()''.  Expressions might
be combined using boolean operators such as the following:</P>
<DL>
<DT><STRONG><A NAME="item_%22and%22_%28equivalent_with_%22%26%26%22%29">``<STRONG>and</STRONG>'' (equivalent with ``<STRONG>&amp;&amp;</STRONG>'')</A></STRONG><BR>
<DD>
Boolean ``and'' of the two expressions, is only true if both expressions are
true.  Example: <EM>expression1</EM> <STRONG>and</STRONG> <EM>expression2</EM>
<P></P>
<DT><STRONG><A NAME="item_%22or%22_%28equivalent_with_%22%7C%7C%22%29">``<STRONG>or</STRONG>'' (equivalent with ``<STRONG>||</STRONG>'')</A></STRONG><BR>
<DD>
Boolean ``or'' of the two expressions, is true if either or both expressions
are true.  Example: <EM>expression1</EM> <STRONG>or</STRONG> <EM>expression2</EM>
<P></P>
<DT><STRONG><A NAME="item_%22not%22_%28equivalent_with_%22%21%22%29">``<STRONG>not</STRONG>'' (equivalent with ``<STRONG>!</STRONG>'')</A></STRONG><BR>
<DD>
Boolean negation of a single expression.  Example:  <STRONG>not</STRONG> <EM>expression</EM> .
Yet another example: <STRONG>!</STRONG><EM>expression</EM>
<P></P></DL>
<P>(For more details on this I recommend a book on Perl)</P>
<P>
<H2><A NAME="predefined filter variables">Predefined Filter Variables</A></H2>
<P>To facilitate, there are a number of predefined values available to use
in the filter.  Note that these variables are also available when templates
interfaces are evaluated (but not host templates).</P>
<P>Caveat:  All these variables' names begin with a dollar sign  ($), which
is a syntactic requirement for scalar variables in Perl.  The danger here
is that the dollar sign in many shells is an active character (often
used for shell variables exactly as in Perl variables) so it is important
to ensure that the Perl expression isn't evaluated by the command line
shell as shell code before being passed to cfgmaker as command line
arguments.  In shells like Bourne shell, ksh shell or bash shell, placing
the entire expression within single qoutes will avoid such accidental
evaluation:</P>
<PRE>
 '--if-filter=($default_iftype &amp;&amp; $if_admin)'</PRE>
<DL>
<DT><STRONG><A NAME="item_%24if_type"><STRONG>$if_type</STRONG></A></STRONG><BR>
<DD>
This is an integer specifying the interface type as
per the SNMP standards and as reported by the polled device.  A complete list
of interface types would be impractical for this document , but there are
a number predefined varables below.  Normally, cfgmaker puts in the target's
PageTop this iftype value within paranthesis after the name of the interface
type. (e.g ``propPointToPointSerial (22)'').
<P>Here's a list of some of the most common interface types by number:</P>
<PRE>
   6 ethernetCsmacd
   7 iso88023Csmacd
   9 iso88025TokenRing
  15 fddi
  19 E1
  20 basicISDN 
  21 primaryISDN
  22 propPointToPointSerial
  23 ppp
  24 softwareLoopback
  30 ds3
  32 frame-relay
  33 rs232
  37 atm
  39 sonet
  44 frameRelayService
  46 hssi
  49 aal5
  53 propVirtual
  62 Fast Ethernet (100BaseT)
  63 ISDN &amp; X.25
  69 Full Duplex Fast Ethernet (100BaseFX)
  94 Asymetric Digital Subscriber Loop (ADSL)
 117 Gigabit Ethernet
 134 ATM Sub Interface</PRE>
<P></P>
<DT><STRONG><A NAME="item_%24default"><STRONG>$default</STRONG></A></STRONG><BR>
<DD>
True if and only if cfgmaker normally should
accepted the interface based on the interfaces administrative and
operational state (taking the flags <STRONG>--no-down</STRONG> and <STRONG>--show-op-down</STRONG> into
account) and it's type (and a few other things).
<P></P>
<DT><STRONG><A NAME="item_%24default_ifstate"><STRONG>$default_ifstate</STRONG></A></STRONG><BR>
<DD>
True if and only if cfgmaker would have accepted the
interface based on it's operational and administrative states (also taking
into account the presence of the flags <STRONG>--no-down</STRONG> and <STRONG>--show-op-down</STRONG>).
<P></P>
<DT><STRONG><A NAME="item_%24default_iftype"><STRONG>$default_iftype</STRONG></A></STRONG><BR>
<DD>
True if and only if cfgmaker would have accepted the
interface based on it's type (and a few type specific details in addition).
<P></P>
<DT><STRONG><A NAME="item_%24if_admin"><STRONG>$if_admin</STRONG></A></STRONG><BR>
<DD>
True if and only if the interface is in an adminstrative up
state.
<P></P>
<DT><STRONG><A NAME="item_%24if_oper"><STRONG>$if_oper</STRONG></A></STRONG><BR>
<DD>
True if and only if the interface is in an operational up
state.
<P></P></DL>
<P>A number of variables are also predefined to easily decide if an interface
belong to a certain cathegory or not.  Below is all those variables listed
together with which if_type numbers each variable will be true for.  Note
that some variables refer to other variables as well.</P>
<DL>
<DT><STRONG><A NAME="item_%24if_is_ethernet"><STRONG>$if_is_ethernet</STRONG></A></STRONG><BR>
<DD>
True for ethernet interfaces (nr 6, 7, 26, 62, 69 and 117).
<P></P>
<DT><STRONG><A NAME="item_%24if_is_isdn"><STRONG>$if_is_isdn</STRONG></A></STRONG><BR>
<DD>
True for various ISDN interface types (nr 20, 21, 63, 75, 76 and 77)
<P></P>
<DT><STRONG><A NAME="item_%24if_is_dialup"><STRONG>$if_is_dialup</STRONG></A></STRONG><BR>
<DD>
True for dial-up interfaces such as PPP as well
as ISDN.  (nr 23, 81, 82 and 108 in addition to the numbers of
<STRONG>$if_is_isdn</STRONG>).
<P></P>
<DT><STRONG><A NAME="item_%24if_is_atm"><STRONG>$if_is_atm</STRONG></A></STRONG><BR>
<DD>
True for miscellaneous ATM related interface types (nr 37, 49, 107, 105,
106, 114 and 134).
<P></P>
<DT><STRONG><A NAME="item_%24if_is_lan"><STRONG>$if_is_lan</STRONG></A></STRONG><BR>
<DD>
True for LAN interfaces (8, 9, 11, 15, 26, 55, 59, 60 and 115 in addition
to the numbers of <STRONG>$if_is_ethernet</STRONG>).
<P></P>
<DT><STRONG><A NAME="item_%24if_is_dsl"><STRONG>$if_is_dsl</STRONG></A></STRONG><BR>
<DD>
True for ADSL, RDSL, HDSL and SDSL (nr 94, 95, 96, 97)
<P></P>
<DT><STRONG><A NAME="item_%24if_is_loopback"><STRONG>$if_is_loopback</STRONG></A></STRONG><BR>
<DD>
True for software loopback interfaces (nr 24)
<P></P>
<DT><STRONG><A NAME="item_%24if_is_ciscovlan"><STRONG>$if_is_ciscovlan</STRONG></A></STRONG><BR>
<DD>
True for Cisco VLAN interfaces (interfaces with the
word Vlan or VLAN in their ifdescs)
<P></P></DL>
<P>Besides of that, all the variables available in cfgmaker is at the scripts
disposal even if the use of such features is discouraged.  More
``shortcuts'' in the form of variables and functions will be made avaiable in
the future instead.</P>
<P>
<H2><A NAME="examples on filters">Examples on Filters</A></H2>
<P>The following filter will not affect which interfaces get's included or
excluded, it will make cfgmaker behave as normally.</P>
<PRE>
 '--if-filter=$default'</PRE>
<P>The following filter will make cfgmaker exclude PPP (23) interfaces:</P>
<PRE>
 '--if-filter=$default &amp;&amp; $if_type!=23'</PRE>
<P>The following filter will make cfgmaker behave as usual except that it will
consider the operational state of an interface irrelevant but still reject
all interfaces which are administratively down.</P>
<PRE>
 '--if-filter=$if_admin &amp;&amp; $default_iftype'</PRE>
<P>
<HR>
<H1><A NAME="details on templates">DETAILS ON TEMPLATES</A></H1>
<P>The contents of the template files are evaluated as a Perl program.  A
number or Perl variables are available for the program to read and others
are used to be written to.</P>
<P>As quite a few of the predefined variables has values which are are supposed
to be used in HTML code some of them have an ``HTML-escaped'' variant, e.g
$html_syslocation is the HTML escaped variant of $syslocation.  The HTML
escaping means that the chars ``&lt;'', ``&gt;'' and ``&amp;'' are replaced by ``&amp;lt;'',
``&amp;gt;'' and ``&amp;amp;'' and that newlines embedded in the string are prepended
with ``&lt;BR&gt;'' and appended with a space character (if a newline is last in the
string it is not touched).</P>
<P>
<H2><A NAME="writable template variables">Writable Template Variables</A></H2>
<P>These are the variables available to store the configuration lines in.
Some of them are initialized prior to the evaluation of the template but
such content normally is comments for inclusion in the final configuration
file so those variables might be reset to the empty string in the template
code to eliminate the comments.  The other way around is also possible, the
contents of these variables might be extended with further information
for various reasons such as debugging etc.</P>
<P>Once the template has been evaluated, the following happens:  if the
template is a interface template and the actual interface for some reason
is rejected and thus needs to be commented out, all the lines in the
variable <STRONG>$target_lines</STRONG> are turned into comments by adding a hash mark
(``#'') at their beginning.  Then all the variables <STRONG>$head_lines</STRONG>,
<STRONG>$problem_lines</STRONG> , <STRONG>$target_lines</STRONG> and <STRONG>$separator_lines</STRONG>
are concatenated together to form the lines to add to the configuration file.</P>
<DL>
<DT><STRONG><A NAME="item_%24target_lines"><STRONG>$target_lines</STRONG></A></STRONG><BR>
<DD>
This variable is the placeholder for the configuration lines created
by the template.  <STRONG>$target_lines</STRONG> is predefined to be empty when
the template code is evaluated.
<P></P>
<DT><STRONG><A NAME="item_%24head_lines"><STRONG>$head_lines</STRONG></A></STRONG><BR>
<DD>
This variable is intended to be the placeholder for the comment line
appearing just before the target in the configuration file.  It is
initialized with that comment line before the evaluation of the template
code and if the template doesn't modify <STRONG>$head_lines</STRONG> during evaluation,
the comment will look like usual in the config file.
<P></P>
<DT><STRONG><A NAME="item_%24problem_lines"><STRONG>$problem_lines</STRONG></A></STRONG><BR>
<DD>
This variable is intended to be the placholder for the comment lines
describing any problems which might have been encountered when trying
to add the target into the configuration.  For host templates it's
normally not used and for those it's predefined as the empty string.
For interface templates <STRONG>$problem_lines</STRONG> is predefined with
the error description comments which cfgmaker normally would use for
rejected interfaces or as the empty string for accepted interfaces.
<P>It is possible to test against <STRONG>$problem_lines</STRONG> to find out if
an interface will be included or rejected but this is not recommended.
Test against <STRONG>$if_ok</STRONG> instead.</P>
<P></P>
<DT><STRONG><A NAME="item_%24separator_lines"><STRONG>$separator_lines</STRONG></A></STRONG><BR>
<DD>
This variable is the placeholder for the string to use as the separator
between the code for individual targets.  The contents of this variable
is put after each target (so the lines will appear after the end of the
last target in the config as well).
<P></P></DL>
<P>
<H2><A NAME="predefined template variables">Predefined Template Variables</A></H2>
<P>All the variables below are available for interface templates to use.
For host templates, only those listed under <A HREF="#host and system variables">Host and System Variables</A>
are available.</P>
<P>For interface templates the variables listed under
<A HREF="#predefined filter variables">Predefined Filter Variables</A> are also available.</P>
<P>
<H3><A NAME="host and system variables">Host and System Variables</A></H3>
<DL>
<DT><STRONG><A NAME="item_%24router_name"><STRONG>$router_name</STRONG></A></STRONG><BR>
<DD>
This is the fully qualified name for the router.  It is affected by the
following items on the command line:  the router name itself and 
<STRONG>--dns-domain</STRONG>.
<P></P>
<DT><STRONG><A NAME="item_%24router_connect"><STRONG>$router_connect</STRONG></A></STRONG><BR>
<DD>
This is the reference string for the router being polled.  It is on the
form community@router possibly followed by some snmp options.  It is
affected by the following items on the command line:  the router name
itself, <STRONG>--community</STRONG>, <STRONG>--snmp-options</STRONG> and <STRONG>--dns-domain</STRONG>.
(There's no HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24directory_name"><STRONG>$directory_name</STRONG></A></STRONG><BR>
<DD>
This variable should contain the directory name as cfgmaker normally would
use as the value for the ``Directory[]'' directive.  The value is determined
by the <STRONG>--subdirs</STRONG> command line option.  If <STRONG>--subdirs</STRONG> isn't specified
<STRONG>$directory_name</STRONG> will be the empty string.  (There's no HTML escaped
variant available)
<P></P>
<DT><STRONG><A NAME="item_%24syscontact"><STRONG>$syscontact</STRONG></A></STRONG><BR>
<DD>
This variable is the router's SNMP sysContact value.  (HTML escaped
variant: <STRONG>$html_syscontact</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24sysname"><STRONG>$sysname</STRONG></A></STRONG><BR>
<DD>
This variable is the router's SNMP sysName value.  (No HTML escaped
variant available)
<P></P>
<DT><STRONG><A NAME="item_%24syslocation"><STRONG>$syslocation</STRONG></A></STRONG><BR>
<DD>
This variable is the router's SNMP sysLocation value.  (HTML escaped
variant: <STRONG>$html_syslocation</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24sysdescr"><STRONG>$sysdescr</STRONG></A></STRONG><BR>
<DD>
This variable is the router's SNMP sysDescr value.  It is normally not used
by cfgmaker but might be useful in a template.  (HTML escaped variant:
<STRONG>$html_sysdescr</STRONG>)
<P></P></DL>
<P>
<H3><A NAME="interface target related variables">Interface Target Related Variables</A></H3>
<DL>
<DT><STRONG><A NAME="item_%24target_name"><STRONG>$target_name</STRONG></A></STRONG><BR>
<DD>
This is what cfgmaker normally would use as the the name of the target.
The target name is what is found within the square brackets, ``[]'', for target
directives.  (There's no HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24if_ref"><STRONG>$if_ref</STRONG></A></STRONG><BR>
<DD>
This the reference string for the interface.  It is expected to be used
in the ``Target[xyz]'' directive to distinguish what interface to use.  The
value of this variable is affected by the <STRONG>--ifref</STRONG> command line option.
It is normally used together with <STRONG>$router_connect</STRONG>. 
(There's no HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24if_ok"><STRONG>$if_ok</STRONG></A></STRONG><BR>
<DD>
This variable is true if the interface is going to be included into the
configuration file, otherwise false.  Don't test against other variables
such as <STRONG>$problem_lines</STRONG> to find out if an interface will be rejected
or not, use this <STRONG>$if_ok</STRONG> instead.
<P></P>
<DT><STRONG><A NAME="item_%24default_target_lines"><STRONG>$default_target_lines</STRONG></A></STRONG><BR>
<DD>
This variable contains all the target lines which cfgmaker by default outputs
for this interface.  It's useful if you want to have the ``standard target''
but want to add some extra lines to it by using a template.
<P></P></DL>
<P>By default cfgmaker uses the following directives for each target it
generates: Target[], SetEnv[], MaxBytes[], Title[], PageTop[] and if
there is any directory specified also the Directory[] directive.</P>
<P>To facilitate the creation of templates which generates target configs
which are similar to the default one, each of the above mentioned
directive lines have a corresponding variable containing the line as
cfgmaker would have output it by default.</P>
<P>Note that none of these have a HTML escaped variant, text in them is
HTML escaped where needed.  Also note that they do not have any newline
at the end.</P>
<DL>
<DT><STRONG><A NAME="item_%24default_target_directive"><STRONG>$default_target_directive</STRONG></A></STRONG><BR>
<DD>
This variable contains the default string for the Target[] directive line.
<P></P>
<DT><STRONG><A NAME="item_%24default_setenv_directive"><STRONG>$default_setenv_directive</STRONG></A></STRONG><BR>
<DD>
This variable contains the default string for the SetEnv[] directive line.
<P></P>
<DT><STRONG><A NAME="item_%24default_directory_directive"><STRONG>$default_directory_directive</STRONG></A></STRONG><BR>
<DD>
This variable contains the default string for the Directory[] directive line
which means it is an empty string (with no newline) if there's no directory.
<P></P>
<DT><STRONG><A NAME="item_%24default_maxbytes_directive"><STRONG>$default_maxbytes_directive</STRONG></A></STRONG><BR>
<DD>
This variable contains the default string for the MaxBytes[] directive line.
<P></P>
<DT><STRONG><A NAME="item_%24default_title_directive"><STRONG>$default_title_directive</STRONG></A></STRONG><BR>
<DD>
This variable contains the default string for the Title[] directive line.
<P></P>
<DT><STRONG><A NAME="item_%24default_pagetop_directive"><STRONG>$default_pagetop_directive</STRONG></A></STRONG><BR>
<DD>
This variable contains the default string for the PageTop[] directive lines.
<P></P></DL>
<P>
<H3><A NAME="interface network configuration variables">Interface Network Configuration Variables</A></H3>
<DL>
<DT><STRONG><A NAME="item_%24if_ip"><STRONG>$if_ip</STRONG></A></STRONG><BR>
<DD>
This variable should contain the IP-address of the interface, if any has
been assigned to it.  (There's no HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24ifindex"><STRONG>$ifindex</STRONG></A></STRONG><BR>
<DD>
This variable is the SNMP ifIndex for the interface which per definition
always is an integer.  (There's no HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24if_index"><STRONG>$if_index</STRONG></A></STRONG><BR>
<DD>
Equivalent with <STRONG>$ifindex</STRONG>.
<P></P>
<DT><STRONG><A NAME="item_%24if_eth"><STRONG>$if_eth</STRONG></A></STRONG><BR>
<DD>
Contains the ethernet address of the interface, if any.  (There's no HTML
escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24if_speed"><STRONG>$if_speed</STRONG></A></STRONG><BR>
<DD>
This variable is the speed in bytes/second (with prefixes).  (There's no
HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24if_speed_str"><STRONG>$if_speed_str</STRONG></A></STRONG><BR>
<DD>
This variable is a cooked speed description which is either in bits or
bytes depending on wether or not the bits option is active and also with
the proper prefix for the speed (k, M, G etc).  (No HTML escaped variant
available)
<P></P>
<DT><STRONG><A NAME="item_%24if_type_desc"><STRONG>$if_type_desc</STRONG></A></STRONG><BR>
<DD>
This variable is a textual description of the interface type.  (HTML
escaped variant: <STRONG>$html_if_type_desc</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_type_num"><STRONG>$if_type_num</STRONG></A></STRONG><BR>
<DD>
This variable the integer value corresponding to the interface type (for a
listing for the value for the more common interface types, see the section
DETAILS ON FILTERS above).  (No HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24if_dns_name"><STRONG>$if_dns_name</STRONG></A></STRONG><BR>
<DD>
This is the DNS name for the interface.  (No HTML escaped variant available)
<P></P></DL>
<P>
<H3><A NAME="interface name, description and alias variables">Interface Name, Description and Alias Variables</A></H3>
<P>It might seem confusing with both <EM>Name</EM>, <EM>Description</EM> and <EM>Alias</EM> in
this context and to some extent it is.  <EM>Name</EM> and <EM>Description</EM> are
usually supported on most equipment but how they are used varies, both
between manufacturers as well as between different cathegories of equipment
from the same manufacturer.  The <EM>Alias</EM> is at least supported by Cisco
IOS, and that variable contains whatever is used in the IOS statement
called ``description'' for the interface (not to be confused with the SNMP
variables for <EM>Description</EM>).</P>
<P>For better control from the command line consider <STRONG>$if_title_desc</STRONG> which contents
are controlled by the <STRONG>--if-descr</STRONG> command line option.</P>
<DL>
<DT><STRONG><A NAME="item_%24if_snmp_descr"><STRONG>$if_snmp_descr</STRONG></A></STRONG><BR>
<DD>
This variable should contain the ``raw'' description of the interface as
determined by the SNMP polling of the router.  (HTML escaped variant:
<STRONG>$html_if_snmp_descr</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_snmp_name"><STRONG>$if_snmp_name</STRONG></A></STRONG><BR>
<DD>
The ``raw'' name for the interface as provided by SNMP polling.  (HTML escaped
variant: <STRONG>$html_if_snmp_name</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_snmp_alias"><STRONG>$if_snmp_alias</STRONG></A></STRONG><BR>
<DD>
The ``raw'' ifAlias for the interface as provided by SNMP polling. (HTML
escaped variant: <STRONG>$html_if_snmp_alias</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_cisco_descr"><STRONG>$if_cisco_descr</STRONG></A></STRONG><BR>
<DD>
The ``raw'' CiscolocIfDescr for the interface as provided by SNMP polling.
(HTML escaped variant: <STRONG>$html_if_cisco_descr</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_description"><STRONG>$if_description</STRONG></A></STRONG><BR>
<DD>
This is the ``cooked'' description string for the interface, taking into account
the SNMP values found for the interface's RDescr, ifAlias and
CiscolocIfDescr.  (HTML escaped variant: <STRONG>$html_if_description</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_title"><STRONG>$if_title</STRONG></A></STRONG><BR>
<DD>
The full string cfgmaker by default would have used for the Title[] directive
in the configuration as well as the content of the topmost H1 tag in the
PageTop[].  Is composed by the contents of <STRONG>$desc_prefix</STRONG>,
<STRONG>$if_title_desc</STRONG> and <STRONG>$sysname</STRONG>.
<P>As <STRONG>$if_title</STRONG> depends on <STRONG>$if_title_desc</STRONG>, it is possible to indirectly
control <STRONG>$if_title</STRONG> by using the command line option <STRONG>--if-descr</STRONG>.</P>
<P>(HTML escaped variant: <STRONG>$html_if_title</STRONG>)</P>
<P></P>
<DT><STRONG><A NAME="item_%24if_port_name"><STRONG>$if_port_name</STRONG></A></STRONG><BR>
<DD>
If the host is a Cisco Catalyst LAN switch, this variable is the name of
that port.  (No HTML escaped variant available)
<P></P>
<DT><STRONG><A NAME="item_%24desc_prefix"><STRONG>$desc_prefix</STRONG></A></STRONG><BR>
<DD>
This variable is a prefix of the description of what the target is to use in 
the ``Title[]'' directive and in the H1 section of the ``PageTop[]''.  Default is
``Traffic analysis for ''.  (HTML escaped variant: <STRONG>$html_desc_prefix</STRONG>)
<P></P>
<DT><STRONG><A NAME="item_%24if_title_desc"><STRONG>$if_title_desc</STRONG></A></STRONG><BR>
<DD>
This is the description of the interface normally used by cfgmaker as part
of the variable <STRONG>$if_title</STRONG>.  The latter is used as the full string in the
``Title[]'' directove and the H1 section in the PageTop[].
<P><STRONG>$if_title_desc</STRONG> is controlled by the command line option <STRONG>--if-descr</STRONG>
which indirectly controls the contents of <STRONG>$if_title</STRONG></P>
<P>(HTML escaped variant: <STRONG>$html_if_title_desc</STRONG>)</P>
<P></P></DL>
<P>
<H2><A NAME="help functions for templates">Help Functions for Templates</A></H2>
<P>The following functions exists to facilitate the writing of host and
interface templates.</P>
<DL>
<DT><STRONG><A NAME="item_html_escape"><STRONG>html_escape(<EM>string</EM>)</STRONG></A></STRONG><BR>
<DD>
<STRONG>html_escape()</STRONG> takes a string as an argument and returns a new string
where the following substitutions has been done:  the chars ``&lt;'', ``&gt;'' and
``&amp;'' are replaced by ``&amp;lt;'', ``&amp;gt;'' and ``&amp;amp;'' and that newlines embedded
in the string are prepended with ``&lt;BR&gt;'' and appended with a space character
(newlines at the end of the string are not touched).
<P></P></DL>
<P>
<H2><A NAME="example template files">Example Template Files</A></H2>
<P>
<H3><A NAME="template example 1: eliminating rejected targets from appearing">Template Example 1: Eliminating Rejected Targets From Appearing</A></H3>
<P>This template file generates exactly the same configuration code per
interface as cfgmaker does by default, with the exception that it eliminates
all lines (comments as well as config code) for an interface if the
interface happens to be rejected.</P>
<PRE>
 if(not $problem_lines)
 {
   $target_lines .= &lt;&lt;ECHO;
</PRE>
<PRE>

 Target[$target_name]: $if_ref:$router_connect
 SetEnv[$target_name]: MRTG_INT_IP=&quot;$if_ip&quot; MRTG_INT_DESCR=&quot;$if_snmp_descr&quot;
 ECHO</PRE>
<PRE>

   if ($directory_name) {
       $target_lines .= &quot;Directory[$target_name]: $directory_name\n&quot;;
   }</PRE>
<PRE>

   $target_lines .= &lt;&lt;ECHO;
 MaxBytes[$target_name]: $if_speed
 Title[$target_name]: $html_desc_prefix$html_if_title_desc -- $sysname
 PageTop[$target_name]: &lt;H1&gt;$html_desc_prefix$html_if_title_desc -- $sysname&lt;/H1&gt;
  &lt;TABLE&gt;
    &lt;TR&gt;&lt;TD&gt;System:&lt;/TD&gt;     &lt;TD&gt;$sysname in $html_syslocation&lt;/TD&gt;&lt;/TR&gt;
    &lt;TR&gt;&lt;TD&gt;Maintainer:&lt;/TD&gt; &lt;TD&gt;$html_syscontact&lt;/TD&gt;&lt;/TR&gt;
    &lt;TR&gt;&lt;TD&gt;Description:&lt;/TD&gt;&lt;TD&gt;$html_if_description&lt;/TD&gt;&lt;/TR&gt;
    &lt;TR&gt;&lt;TD&gt;ifType:&lt;/TD&gt;     &lt;TD&gt;$html_if_type_desc ($if_type_num)&lt;/TD&gt;&lt;/TR&gt;
    &lt;TR&gt;&lt;TD&gt;ifName:&lt;/TD&gt;     &lt;TD&gt;$html_if_snmp_name&lt;/TD&gt;&lt;/TR&gt;
 ECHO</PRE>
<PRE>

   $target_lines .= &lt;&lt;ECHO if defined $if_port_name;
    &lt;TR&gt;&lt;TD&gt;Port Name:&lt;/TD&gt;  &lt;TD&gt;$if_port_name&lt;/TD&gt;&lt;/TR&gt;
 ECHO</PRE>
<PRE>

   $target_lines .= &lt;&lt;ECHO;
    &lt;TR&gt;&lt;TD&gt;Max Speed:&lt;/TD&gt;  &lt;TD&gt;$if_speed_str&lt;/TD&gt;&lt;/TR&gt;
 ECHO</PRE>
<PRE>

   $target_lines .= &lt;&lt;ECHO if $if_ip;
    &lt;TR&gt;&lt;TD&gt;Ip:&lt;/TD&gt;         &lt;TD&gt;$if_ip ($if_dns_name)&lt;/TD&gt;&lt;/TR&gt;
 ECHO</PRE>
<PRE>

   $target_lines .= &lt;&lt;ECHO;
  &lt;/TABLE&gt;
 ECHO
 } else {
   $head_lines=&quot;&quot;;
   $problem_lines=&quot;&quot;;
   $target_lines=&quot;&quot;;
   $separator_lines=&quot;&quot;;
 }</PRE>
<P>
<H3><A NAME="template example 2: simplier version of example 1">Template Example 2: Simplier Version of Example 1</A></H3>
<P>Example 1 was partly intended to demonstrate how to customize the generation
of interface targets but also to provide a hint of how the variables are
used in the ``default'' template which one could consider that cfgmaker
normally uses.</P>
<P>If you're only intrested in the easiest way of entirely eliminating those
reject interfaces, the template below would do the job as well by using
<STRONG>$default_target_lines</STRONG>.</P>
<PRE>
 if($if_ok) {
  $target_lines = $default_target_lines;
 } else {
   $head_lines=&quot;&quot;;
   $problem_lines=&quot;&quot;;
   $target_lines=&quot;&quot;;
   $separator_lines=&quot;&quot;;
 }
</PRE>
<PRE>

=head3 Template Example 3: Creating CPU Targets for Hosts</PRE>
<P>Below is an example of a host template.</P>
<PRE>
 $head_lines .= &lt;&lt;ECHO;
 #---------------------------------------------------------------------
 ECHO</PRE>
<PRE>
 my $target_name = $router_name . &quot;.cpu&quot;;</PRE>
<PRE>
 $target_lines .= &lt;&lt;ECHO;
</PRE>
<PRE>

 YLegend[$target_name]: Percentage CPU load
 ShortLegend[$target_name]: %
 Legend1[$target_name]: CPU load in %
 Legend2[$target_name]: 
 Legend3[$target_name]: Max Observed CPU load
 Legend4[$target_name]: 
 LegendI[$target_name]: &amp;nbsp;CPU Load:
 LegendO[$target_name]: 
 WithPeak[$target_name]: ywm
 MaxBytes[$target_name]: 100
 Options[$target_name]: growright, gauge, nopercent
 Title[$target_name]: $router_name CPU load
 Target[$target_name]: 1.3.6.1.4.1.9.2.1.58.0&amp;1.3.6.1.4.1.9.2.1.58.0:$router_connect
 PageTop[$target_name]: &lt;H1&gt;$router_name CPU load&lt;/H1&gt;
   &lt;TABLE&gt;
     &lt;TR&gt;&lt;TD&gt;System:&lt;/TD&gt;&lt;TD&gt;$router_name in $html_syslocation&lt;/TD&gt;&lt;/TR&gt;
     &lt;TR&gt;&lt;TD&gt;Maintainer:&lt;/TD&gt;&lt;TD&gt;$html_syscontact&lt;/TD&gt;&lt;/TR&gt;
     &lt;TR&gt;&lt;TD VALIGN=&quot;top&quot;&gt;Description:&lt;/TD&gt;&lt;TD&gt;$html_sysdescr&lt;/TD&gt;&lt;/TR&gt;
     &lt;TR&gt;&lt;TD&gt;Resource:&lt;/TD&gt;&lt;TD&gt;CPU.&lt;/TD&gt;&lt;/TR&gt;
   &lt;/TABLE&gt;
 ECHO</PRE>
<P>
<HR>
<H1><A NAME="examples">EXAMPLES</A></H1>
<P>The first example creates a config file for <EM>router.place.xyz</EM>:  the router           
has the community name <EM>public</EM>.  Interfaces get identified by their             
IP number.  Two global options get added to the config file.  The                 
config file gets redirected to <EM>mrtg.conf</EM>.  The '\' signs at the end            
of the line mean that this command should be written on a single line.</P>
<PRE>
 cfgmaker --global &quot;WorkDir: /home/tobi&quot;           \
          --global &quot;Options[_]: growright,bits&quot;    \
          --ifref=ip                               \
          public@router.place.xyz &gt; mrtg.cfg</PRE>
<P>The next example creates a config file for four devices:
<EM>router1.place.xyz</EM>, <EM>router2.place.xyz</EM>, <EM>switch1.place.xyz</EM> and
<EM>switch2.place.xyz</EM> all with the community <EM>public</EM>.</P>
<P>The two routers will have <STRONG>--ifref</STRONG> set to <STRONG>descr</STRONG> whilst the two
switches will use <STRONG>--ifref</STRONG> set to <STRONG>name</STRONG>.  Further the routers will
use <STRONG>--ifdesc</STRONG> set to <STRONG>alias</STRONG> and <EM>switch1.place.xyz</EM> will use
<STRONG>--ifdesc</STRONG> set to <STRONG>descr</STRONG> whilst <EM>switch2.place.xyz</EM> use <STRONG>name</STRONG> instead.</P>
<P>Finally, there will be two Options lines inserted in the configuration:
One will be in the beginning, whilst the other will be inserted after
the lines related to the two routers but before those lines related
to the switches.</P>
<PRE>
 cfgmaker --global &quot;WorkDir: /home/tobi&quot;           \
          --global &quot;Options[_]: growright,bits&quot;    \
          --ifref=descr                            \
          --ifdesc=alias                           \
          public@router1.place.xyz                 \
          public@router2.place.xyz                 \
          --global &quot;Options[_]: growright&quot;         \
          --ifref=name                             \
          --ifdesc=descr                           \
          public@switch1.place.xyz                 \
          --ifdesc=name                            \
          public@switch2.place.xyz &gt; mrtg.cfg</PRE>
<P>The next example demonstrates how to use the <STRONG>--community</STRONG>,
<STRONG>--snmp-options</STRONG> and <STRONG>--dns-domain</STRONG> to make the command line
simpler.  All the equipment will use the community <EM>hidden</EM>, except for
the ppp-server which use community <EM>access</EM>.  All equipment uses these
SNMP options: <STRONG>1s timeout</STRONG>, <STRONG>1 retry</STRONG> and <STRONG>SNMP version 2</STRONG> (<STRONG>backoff</STRONG> and
<STRONG>port</STRONG> is unspecified which means they use the default values).
The exception again is the ppp-server which uses <STRONG>SNMP version 1</STRONG>.
Finally, all the equipment is part of the domain <EM>place.xyz</EM>, except
for the ppp-server which is part of the domain <EM>remote.place.xyz</EM>.
Note that the latter is achieved simply by specifying the name
of the ppp-server to be <EM>ppp-server.<STRONG>remote</STRONG></EM> .</P>
<PRE>
 cfgmaker --global &quot;WorkDir: /home/tobi&quot;           \
          --global &quot;Options[_]: growright,bits&quot;    \
          --dns-domain=place.xyz                   \
          --community=hidden                       \
          --snmp-options=::1:1::2                  \
          router1                                  \
          router2                                  \
          router3                                  \
          router4                                  \
          router5                                  \
          switch1                                  \
          switch2                                  \
          switch3                                  \
          switch4                                  \
          switch5                                  \
          switch6                                  \
          switch7                                  \
          access@ppp-server.remote:::::1 &gt; mrtg.cfg</PRE>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P><A HREF="reference.html">the reference manpage</A></P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Tobias Oetiker &lt;<A HREF="mailto:tobi@oetiker.ch">tobi@oetiker.ch</A>&gt; and
Jakob Ilves &lt;<A HREF="mailto:jakob.ilves@oracle.com">jakob.ilves@oracle.com</A>&gt;</P>
<P>
<HR>
<H1><A NAME="license">LICENSE</A></H1>
<P>GNU General Public License</P>
<P>
<HR>
<H1><A NAME="copyright">COPYRIGHT</A></H1>
<P>Cfgmaker is Copyright 2000 by Tobias Oetiker &lt;<A HREF="mailto:tobi@oetiker.ch">tobi@oetiker.ch</A>&gt;</P>

</BODY>

</HTML>