1CFGMAKER(1)                          mrtg                          CFGMAKER(1)
2
3
4

NAME

6       cfgmaker - Creates mrtg.cfg files (for mrtg-2.16.2)
7

SYNOPSIS

9       cfgmaker [options] [community@]router [[options] [community@]router
10       ...]
11

OPTIONS

13        --ifref=nr    interface references by Interface Number (default)
14        --ifref=ip                     ... by Ip Address
15        --ifref=eth                        ... by Ethernet Number
16        --ifref=descr                      ... by Interface Description
17        --ifref=name                       ... by Interface Name
18        --ifref=type                       ... by Interface Type
19
20        --ifdesc=nr       interface description uses Interface Number (default)
21        --ifdesc=ip                        ... uses Ip Address
22        --ifdesc=eth                       ... uses Ethernet Number
23        --ifdesc=descr                     ... uses Interface Description
24        --ifdesc=name                      ... uses Interface Name
25        --ifdesc=catname                   ... uses CatOS Interface Name
26        --ifdesc=ppname                    ... uses Passport Port Name
27        --ifdesc=alias                     ... uses Interface Alias
28        --ifdesc=type                      ... uses Interface Type
29
30        --if-filter=f     Test every interface against filter f to decide wether
31                          or not to include that interface into the collection.
32                          Currently f is being evaluated as a Perl expression
33                          and it's truth value is used to reject or accept the
34                          interface.
35                          (Experimental, under development, might change)
36
37        --if-template=templatefile
38                          Replace the normal target entries for the interfaces
39                          with an entry as specified by the contents in the file
40                          templatefile.  The file is supposed to contain Perl
41                          code to be executed to generate the lines for the
42                          target in the configuration file.
43                          (Experimental, under development, might change)
44
45        --host-template=templatefile
46                          In addition to creating targets for a host's interfaces
47                          do also create targets for the host itself as specified
48                          by the contents in the file templatefile.  The file is
49                          supposed to contain Perl code to be executed to generate
50                          the lines for the host related targets (such as CPU,
51                          ping response time measurements etc.) in the config-
52                          uration file.
53                          (Experimental, under development, might change)
54
55        --global "x: a"   add global config entries
56
57        --no-down         do not look at admin or opr status of interfaces
58
59        --show-op-down    show interfaces which are operatively down
60
61        --zero-speed=spd  use this speed in bits-per-second as the interface
62                          speed for all interfaces that return a speed of 0
63                          via ifSpeed/ifHighSpeed.  100Mbps = 100000000
64
65        --subdirs=format  give each router its own subdirectory, naming each per
66                          "format", in which HOSTNAME and SNMPNAME will be
67                          replaced by the values of those items -- for instance,
68                          --subdirs=HOSTNAME or --subdirs="HOSTNAME (SNMPNAME)"
69
70        --noreversedns    do not reverse lookup ip numbers
71
72        --community=cmty  Set the default community string to "cmty" instead of
73                          "public".
74
75        --enable-ipv6     Enable IPv6 support, if the required libraries are
76                          present. Numeric IPv6 addresses must be enclosed
77                          in square brackets, e.g. public@[2001:760:4::1]:161
78
79        --use-16bit       Use 16bit SNMP request IDs to query all routers.
80
81        --snmp-options=:[<port>][:[<tmout>][:[<retr>][:[<backoff>][:<ver>]]]]
82
83                          Specify default SNMP options to be appended to all
84                          routers following.  Individual fields can be empty.
85                          Routers following might override some or all of the
86                  options given to --snmp-options.
87
88        --dns-domain=domain
89                  Specifies a domain to append to the name of all
90                  routers following.
91
92        --nointerfaces    Don't do generate any configuration lines for interfaces,
93                          skip the step of gathering interface information and
94                          don't run any interface template code.
95
96        --interfaces      Generate configuration lines for interfaces (this is the
97                          default).  The main purpose of this option is to negate
98                          an --nointerfaces appearing earlier on the command line.
99
100        --help            brief help message
101        --man             full documentation
102        --version         print the version of cfgmaker
103
104        --output=file     output filename default is STDOUT
105

DESCRIPTION

107       Cfgmaker creates MRTG configuration files based on information pulled
108       from a router or another SNMP manageable device.
109
110       [community@]router
111
112       Community is the community name of the device you want to create a con‐
113       figuration for. If not specified, it defaults to 'public'; you might
114       want to try this first if you do not know the community name of a
115       device. If you are using the wrong community name you will get no
116       response from the device.
117
118       Router is the DNS name or the IP number of an SNMP-managable device.
119       Following the name you can specify 6 further options separated by
120       colons.  The full syntax looks like this:
121
122       router[:[prt][:[tmout][:[retr][:[backoff][:vers]]]]]
123
124       Of special interest may be the last parameter, vers.  If you set this
125       to '2' then your device will be queried with SNMP version 2 requests.
126       This allows to poll the 64 bit traffic counters in the device and will
127       thus work much better with fast interfaces (no more counter overrun).
128       Note that the order in which the routers are specified on the command
129       line do matter as the same order is used when the configuration file is
130       generated.  The first specified router has it's configuration lines
131       genrated first, followed by the lines belonging to the next router and
132       so on.
133
134       Note that the first line of the generated cfg file will contain all the
135       commandline options you used for generating it. This is to allow for
136       the easy 'regeneration' in case you want to add newhosts or make some
137       other global change.
138
139       Configuration
140
141       Except for the --output and --global options, all options affect only
142       the routers following them on the command line.  If an option specified
143       earlier on the command line reappears later on the command line with
144       another value, the new value overrides the old value as far as remain‐
145       ing routers are concerned.  This way options might be tailored for
146       groups of routers or for individual routers.
147
148       See --output and --global for how their behaviour is affected by where
149       or how many times they appear on the command line.
150
151       See the Examples below on how to set an option differently for multiple
152       routers.
153
154       --help
155           Print a brief help message and exit.
156
157       --man
158           Prints the manual page and exits.
159
160       --version
161           Print the version of cfgmaker.  This should match the version of
162           MRTG for which config files are being created.
163
164       --ifref nr|ip|eth|descr|name
165           Select the interface identification method.  Default is nr which
166           identifies the router interfaces by their number.  Unfortunately
167           the interface numbering scheme in an SNMP tree can change. Some
168           routers change their numbering when new interfaces are added, oth‐
169           ers change thier numbering every full moon just for fun.
170
171           To work around this sad problem MRTG can identify interfaces by 4
172           other properties. None of these works for all interfaces, but you
173           should be able to find one which does fine for you. Note that espe‐
174           cially ethernet addrsses can be problematic as some routers have
175           the same ethernet address on most of their interface cards.
176
177           Select ip to identify the interface by its IP number. Use eth to
178           use the ethernet address for identification. Use descr to use the
179           Interface description. Or use name to use the Interface name.
180
181           If your chosen method does not allow unique interface identifica‐
182           tion on the device you are querying, cfgmaker will tell you about
183           it.
184
185       --ifdesc nr|ip|eth|descr|name|type|alias
186           Select what to use as the description of the interface.  The
187           description appears in the "Title[]" property for the target as
188           well as the text header in the HTML code defined in the target's
189           "PageTop[]".  Default is to use nr which is just the interface num‐
190           ber which isn't always useful to the viewer of the graphs.
191
192           There are 6 other properties which could be used.  Use ip if you
193           want to use the interface's IP-address.  Use eth if you want to use
194           the interface's ethernet address.  If you want a better descrip‐
195           tion, you can use either descr, name or alias.  Exactly what each
196           of these do varies between different equipment so you might need to
197           experiment.  For instance, for a serial interface on a Cisco router
198           running IOS using name might result in "S0" being the interface
199           description , descr might result in "Serial0" and alias might
200           result in "Link to HQ" (provided that is what is used as the inter‐
201           face's "description" in the router's configuration).
202
203           Finally, if you want to describe the interface by it's Btype (i.e
204           "ethernetCSMA", "propPointtoPoint" etc) you can use type.
205
206       --if-filter 'filter-expression'
207           First of all, this is under some developement and is experimental.
208
209           Use this if you want to have better control over what interfaces
210           gets included into the configuration.  The filter-expression is
211           evaluated as a piece of Perl code and is expected to return a truth
212           value.  If true, include the interface and if false, exclude the
213           interface.
214
215           For a further discussion on how these filters work, see the section
216           "Details on Filters" below.
217
218       --if-template template-file
219           First of all, this is under some development and is experimental.
220
221           Use this if you want to control what the line for each target
222           should look like in the configuration file.  The contents of the
223           file template-file will be evaluated as a Perl program which gener‐
224           ates the lines using certain variables for input and output.
225
226           For a further discussion on how these templates work, see the sec‐
227           tion "Details on Temaplates" below.
228
229       --host-template template-file
230           First of all, this is under some development and is experimental.
231
232           Use this if you want to have some extra targets related to the host
233           itself such as CPU utilization, ping response time to the host,
234           number of busy modems etc.  The contents of the file template-file
235           will be evaluated once per host as a Perl program which generates
236           the lines using certain variables for input and output.
237
238           For a further discussion on how these templates work, see the sec‐
239           tion "Details on Templates" below.
240
241       --community community-string
242           Use this to set the community for the routers following on the com‐
243           mand line to community-string.  Individual routers might overrride
244           this community string by using the syntax community@router.
245
246       --enable-ipv6
247           This option enables IPv6 support. It requires the appropriate perl
248           modules; if they are not found then IPv6 is disabled (see the ipv6
249           documentation).
250
251           cfgmaker will use IPv6 or IPv4 depending on the target. If the tar‐
252           get is a numeric address, the protocol depends on the type of
253           address. If the target is a hostname, cfgmaker will try to resolve
254           the name first to an IPv6 address then to an IPv4 address.
255
256           IPv6 numeric addresses must be specified between square braces.
257
258           For example:
259
260            cfgmaker --enable-ipv6 [2001:760:4::1]:165:::2
261
262           If the target has both an IPv6 address and an IPv4 address with the
263           same hostname, cfgmaker first queries the target using IPv6 and
264           falls back to IPv4 if it fails. This is useful for targets which
265           don't support SNMP over IPv6.
266
267       --use-16bit
268           This option forces the use of 16bit SNMP request IDs.  Some broken
269           SNMP agents do not accept 32bit request IDs.  Try to avoid this
270           option as much as possible, complain to your agent vendor instead.
271
272       --snmp-options  :[port][:[timeout][:[retries][:[backoff][:version]]]]
273           Use this to set the default SNMP options for all routers following
274           on the command line.  Individual values might be omitted as well as
275           trailing colons.  Note that routers might override individual (or
276           all) values specified by --snmp-options by using the syntax
277
278           router[:[port][:[timeout][:[retries][:[backoff][:version]]]]]
279
280       --global "bla: abc"
281           Use this to add global options to the generated config file.  You
282           can call --global several times to add multiple options.  The line
283           will appear in the configuration just before the config for the
284           next router appearing on the command line.
285
286            --global "workdir: /home/mrtg"
287
288           If you want some default Options you might want to put
289
290            --global "options[_]: growright,bits"
291
292           Specifying --global after the last router on the command line will
293           create a line in the configuration file which will appear after all
294           the routers.
295
296       --noreversedns
297           Do not try to reverse lookup IP numbers ... a must for DNS free
298           environments.
299
300       --no-down
301           Normally cfgmaker will not include interfaces which are marked any‐
302           thing but administratively and operationally UP. With this switch
303           you get them all.
304
305       --show-op-down
306           Include interfaces which are operatively down.
307
308       --zero-speed speed
309           Assign this speed in bits-per-second to all interfaces which return
310           0 for ifSpeed and ifHighSpeed.  Some switches, notably Foundry
311           equipment, return a speed of zero for some interfaces.  For exam‐
312           ple, to have all interfaces reporting zero set to 100Mbps, use
313           --zero-speed=100000000.
314
315       --subdirs format
316           Give each router its own subdirectory for the HTML and graphics (or
317           .rrd) files.  The directory name is the given format string with a
318           couple of pattern replacements.  The string "HOSTNAME" will be
319           replaced by the hostname of the router (however you specified it on
320           the cfgmaker commandline -- it may be an actual hostname or just an
321           IP address), and "SNMPNAME" will be replaced with the device's idea
322           of its own name (the same name that appears on the right side of
323           the "Title" lines).  For instance, a call like:
324
325            cfgmaker --subdirs=HOSTNAME__SNMPNAME public@10.10.0.18
326
327           would result in the generation of lines looking something like:
328
329            Directory[10.10.0.18_1]: 10.10.0.18__fp2200-bothrip-1.3
330
331       --output file
332           Write the output from cfgmaker into the file file. The default is
333           to use "STDOUT". --output is expected to appear only once on the
334           command line. If used multiple times, the file specified by the
335           last --output will be used.
336
337       --nointerfaces
338           Don't generate configuration lines for interfaces.
339
340           This makes cfgmaker skip all steps related to interfaces which
341           means it will not do any polling of the router to retrieve inter‐
342           face information which speeds up the execution of cfgmaker and it
343           will neither run any interface templates.
344
345       --interfaces
346           This makes cfgmaker generate configuration lines for interfaces
347           (the default behaviour).
348
349           The main usage of this option is to negate an --nointerfaces
350           appearing earlier on the command line.
351
352       SNMP V3 Options
353
354       Cfgmaker supports SNMP V3 using the Net:SNMP perl module.  There are
355       optional parameters affecting SNMP operation.
356
357       --enablesnmpv3 {yes|no}
358           The --enablesnmpv3 option is an optional flag to check for the
359           presence of the Net::SNMP libraries.  Cfgmaker will try to deter‐
360           mine whether this flag is required and will set the values automat‐
361           ically.
362
363       SNMPv3 Arguments
364
365       A SNMP context is a collection of management information accessible by
366       a SNMP entity.  An item of management information may exist in more
367       than one context and a SNMP entity potentially has access to many con‐
368       texts.  The combination of a contextEngineID and a contextName unam‐
369       biguously identifies a context within an administrative domain.  In a
370       SNMPv3 message, the contextEngineID and contextName are included as
371       part of the scopedPDU.  All methods that generate a SNMP message
372       optionally take a --contextengineid and --contextname argument to con‐
373       figure these fields.
374
375       Context Engine ID
376           The --contextengineid argument expects a hexadecimal string repre‐
377           senting the desired contextEngineID.  The string must be 10 to 64
378           characters (5 to 32 octets) long and can be prefixed with an
379           optional "0x".  Once the --contextengineid is specified it stays
380           with the object until it is changed again or reset to default by
381           passing in the undefined value.  By default, the contextEngineID is
382           set to match the authoritativeEngineID of the authoritative SNMP
383           engine.
384
385       Context Name
386           The contextName is passed as a string which must be 0 to 32 octets
387           in length using the --contextname argument.  The contextName stays
388           with the object until it is changed.  The contextName defaults to
389           an empty string which represents the "default" context.
390
391       User-based Security Model Arguments
392
393       The User-based Security Model (USM) used by SNMPv3 requires that a
394       securityName be specified using the --username argument.  The creation
395       of a Net::SNMP object with the version set to SNMPv3 will fail if the
396       --username argument is not present.  The --username argument expects a
397       string 1 to 32 octets in length.
398
399       Different levels of security are allowed by the User-based Security
400       Model which address authentication and privacy concerns.  A SNMPv3 tar‐
401       get will derive the security level (securityLevel) based on which of
402       the following arguments are specified.
403
404       By default a securityLevel of 'noAuthNoPriv' is assumed.  If the
405       --authkey or --authpassword arguments are specified, the securityLevel
406       becomes 'authNoPriv'.  The --authpassword argument expects a string
407       which is at least 1 octet in length.  Optionally, the --authkey argu‐
408       ment can be used so that a plain text password does not have to be
409       specified in a script.  The --authkey argument expects a hexadecimal
410       string produced by localizing the password with the authorita‐
411       tiveEngineID for the specific destination device.  The "snmpkey" util‐
412       ity included with the Net::SNMP  distribution can be used to create the
413       hexadecimal string (see snmpkey).
414
415       Two different hash algorithms are defined by SNMPv3 which can be used
416       by the Security Model for authentication.  These algorithms are
417       HMAC-MD5-96 "MD5" (RFC 1321) and HMAC-SHA-96 "SHA-1" (NIST FIPS PUB
418       180-1).   The default algorithm used by the module is HMAC-MD5-96.
419       This behavior can be changed by using the --authprotocol argument.
420       This argument expects either the string 'md5' or 'sha' to be passed to
421       modify the hash algorithm.
422
423       By specifying the arguments --privkey or --privpassword the secu‐
424       rityLevel associated with the object becomes 'authPriv'.  According to
425       SNMPv3, privacy requires the use of authentication.  Therefore, if
426       either of these two arguments are present and the --authkey or --auth‐
427       password arguments are missing, the creation of the object fails.  The
428       --privkey and --privpassword arguments expect the same input as the
429       --authkey and --authpassword arguments respectively.
430
431       The User-based Security Model described in RFC 3414 defines a single
432       encryption protocol to be used for privacy.  This protocol, CBC-DES
433       "DES" (NIST FIPS PUB 46-1), is used by default or if the string 'des'
434       is passed to the --privprotocol argument.  By working with the Extended
435       Security Options Consortium http://www.snmp.com/eso/, the module also
436       supports additional protocols which have been defined in draft specifi‐
437       cations.  The draft
438       http://www.snmp.com/eso/draft-reeder-snmpv3-usm-3desede-00.txt defines
439       the support of CBC-3DES-EDE "Triple-DES" (NIST FIPS 46-3) in the User-
440       based Security Model.  This protocol can be selected using the
441       --privprotocol argument with the string '3desede'.  The draft
442       http://www.snmp.com/eso/draft-blumenthal-aes-usm-04.txt describes the
443       use of CFB128-AES-128/192/256 "AES" (NIST FIPS PUB 197) in the USM. The
444       three AES encryption protocols, differentiated by their key sizes, can
445       be selected by passing 'aescfb128', 'aescfb192', or 'aescfb256' to the
446       -privprotocol argument.
447
448       Details on Filters
449
450       The purpose of the filters is to decide which interfaces to accept and
451       which interfaces to reject.  This decision is done for each interface
452       by evaluating the filter expression as a piece of Perl code and inves‐
453       tigating the result of the evaluation.  If true, accept the interface
454       otherwise reject it.
455
456       When working with filters, remember that Perl has it's own idea of what
457       truth and false is.  The empty string "" and the string "0" are false,
458       all other strings are true.  This further imples that any integer value
459       of 0 is false as well as any undef value.  It also implies that all
460       references are considered true.
461
462       As the filter is evaluated as a Perl expression, several useful con‐
463       structs in Perl are worth mentioning:
464
465       Expressions might be grouped by using parentheses "()".  Expressions
466       might be combined using boolean operators such as the following:
467
468       "and" (equivalent with "&&")
469           Boolean "and" of the two expressions, is only true if both expres‐
470           sions are true.  Example: expression1 and expression2
471
472       "or" (equivalent with "||")
473           Boolean "or" of the two expressions, is true if either or both
474           expressions are true.  Example: expression1 or expression2
475
476       "not" (equivalent with "!")
477           Boolean negation of a single expression.  Example:  not expression
478           .  Yet another example: !expression
479
480       (For more details on this I recommend a book on Perl)
481
482       Predefined Filter Variables
483
484       To facilitate, there are a number of predefined values available to use
485       in the filter.  Note that these variables are also available when tem‐
486       plates interfaces are evaluated (but not host templates).
487
488       Caveat:  All these variables' names begin with a dollar sign  ($),
489       which is a syntactic requirement for scalar variables in Perl.  The
490       danger here is that the dollar sign in many shells is an active charac‐
491       ter (often used for shell variables exactly as in Perl variables) so it
492       is important to ensure that the Perl expression isn't evaluated by the
493       command line shell as shell code before being passed to cfgmaker as
494       command line arguments.  In shells like Bourne shell, ksh shell or bash
495       shell, placing the entire expression within single qoutes will avoid
496       such accidental evaluation:
497
498        '--if-filter=($default_iftype && $if_admin)'
499
500       $if_type
501           This is an integer specifying the interface type as per the SNMP
502           standards and as reported by the polled device.  A complete list of
503           interface types would be impractical for this document , but there
504           are a number predefined varables below.  Normally, cfgmaker puts in
505           the target's PageTop this iftype value within paranthesis after the
506           name of the interface type. (e.g "propPointToPointSerial (22)").
507
508           Here's a list of some of the most common interface types by number:
509
510              6 ethernetCsmacd
511              7 iso88023Csmacd
512              9 iso88025TokenRing
513             15 fddi
514             19 E1
515             20 basicISDN
516             21 primaryISDN
517             22 propPointToPointSerial
518             23 ppp
519             24 softwareLoopback
520             30 ds3
521             32 frame-relay
522             33 rs232
523             37 atm
524             39 sonet
525             44 frameRelayService
526             46 hssi
527             49 aal5
528             53 propVirtual
529             62 Fast Ethernet (100BaseT)
530             63 ISDN & X.25
531             69 Full Duplex Fast Ethernet (100BaseFX)
532             94 Asymetric Digital Subscriber Loop (ADSL)
533            117 Gigabit Ethernet
534            134 ATM Sub Interface
535
536       $default
537           True if and only if cfgmaker normally should accepted the interface
538           based on the interfaces administrative and operational state (tak‐
539           ing the flags --no-down and --show-op-down into account) and it's
540           type (and a few other things).
541
542       $default_ifstate
543           True if and only if cfgmaker would have accepted the interface
544           based on it's operational and administrative states (also taking
545           into account the presence of the flags --no-down and
546           --show-op-down).
547
548       $default_iftype
549           True if and only if cfgmaker would have accepted the interface
550           based on it's type (and a few type specific details in addition).
551
552       $if_admin
553           True if and only if the interface is in an adminstrative up state.
554
555       $if_oper
556           True if and only if the interface is in an operational up state.
557
558       A number of variables are also predefined to easily decide if an inter‐
559       face belong to a certain cathegory or not.  Below is all those vari‐
560       ables listed together with which if_type numbers each variable will be
561       true for.  Note that some variables refer to other variables as well.
562
563       $if_is_ethernet
564           True for ethernet interfaces (nr 6, 7, 26, 62, 69 and 117).
565
566       $if_is_isdn
567           True for various ISDN interface types (nr 20, 21, 63, 75, 76 and
568           77)
569
570       $if_is_dialup
571           True for dial-up interfaces such as PPP as well as ISDN.  (nr 23,
572           81, 82 and 108 in addition to the numbers of $if_is_isdn).
573
574       $if_is_atm
575           True for miscellaneous ATM related interface types (nr 37, 49, 107,
576           105, 106, 114 and 134).
577
578       $if_is_wan
579           True for WAN interfaces point to point, Frame Relay and High Speed
580           Serial ( 22,32,44,46)
581
582       $if_is_lan
583           True for LAN interfaces (8, 9, 11, 15, 26, 55, 59, 60 and 115 in
584           addition to the numbers of $if_is_ethernet).
585
586       $if_is_dsl
587           True for ADSL, RDSL, HDSL and SDSL (nr 94, 95, 96, 97)
588
589       $if_is_loopback
590           True for software loopback interfaces (nr 24)
591
592       $if_is_ciscovlan
593           True for Cisco VLAN interfaces (interfaces with the word Vlan or
594           VLAN in their ifdescs)
595
596       $if_vlan_id
597           Returns the vlan id associated with a specific port on Cisco Cata‐
598           lyst switches under both Catalyst OS and IOS, and 3Com switches.
599           If it is not a vlan interface, will return undef.
600
601       $if_cisco_trunk
602           Returns the trunking state of a specific port on Cisco Catalyst
603           switches under both Catalyst OS and IOS.  Returns "1" if the inter‐
604           face is a trunk, undef otherwise.
605
606       $if_MTU
607           Returns the Maximum Transfer Unit associated with a specific port.
608
609       Besides that, you can also use the variables defined for templates
610       below.  Further, all the variables available in cfgmaker is at the
611       scripts disposal even if the use of such features is discouraged.  More
612       "shortcuts" in the form of variables and functions will be made ava‐
613       iable in the future instead.
614
615       Examples on Filters
616
617       The following filter will not affect which interfaces get's included or
618       excluded, it will make cfgmaker behave as normally.
619
620        '--if-filter=$default'
621
622       The following filter will make cfgmaker exclude PPP (23) interfaces:
623
624        '--if-filter=$default && $if_type!=23'
625
626       The following filter will make cfgmaker behave as usual except that it
627       will consider the operational state of an interface irrelevant but
628       still reject all interfaces which are administratively down.
629
630        '--if-filter=$if_admin && $default_iftype'
631
632       Details on Templates
633
634       The contents of the template files are evaluated as a Perl program.  A
635       number or Perl variables are available for the program to read and oth‐
636       ers are used to be written to.
637
638       As quite a few of the predefined variables has values which are are
639       supposed to be used in HTML code some of them have an "HTML-escaped"
640       variant, e.g $html_syslocation is the HTML escaped variant of $sysloca‐
641       tion.  The HTML escaping means that the chars "<", ">" and "&" are
642       replaced by "&lt;", "&gt;" and "&amp;" and that newlines embedded in
643       the string are prepended with "<BR>" and appended with a space charac‐
644       ter (if a newline is last in the string it is not touched).
645
646       Writable Template Variables
647
648       These are the variables available to store the configuration lines in.
649       Some of them are initialized prior to the evaluation of the template
650       but such content normally is comments for inclusion in the final con‐
651       figuration file so those variables might be reset to the empty string
652       in the template code to eliminate the comments.  The other way around
653       is also possible, the contents of these variables might be extended
654       with further information for various reasons such as debugging etc.
655
656       Once the template has been evaluated, the following happens:  if the
657       template is a interface template and the actual interface for some rea‐
658       son is rejected and thus needs to be commented out, all the lines in
659       the variable $target_lines are turned into comments by adding a hash
660       mark ("#") at their beginning.  Then all the variables $head_lines,
661       $problem_lines , $target_lines and $separator_lines are concatenated
662       together to form the lines to add to the configuration file.
663
664       $target_lines
665           This variable is the placeholder for the configuration lines cre‐
666           ated by the template.  $target_lines is predefined to be empty when
667           the template code is evaluated.
668
669       $head_lines
670           This variable is intended to be the placeholder for the comment
671           line appearing just before the target in the configuration file.
672           It is initialized with that comment line before the evaluation of
673           the template code and if the template doesn't modify $head_lines
674           during evaluation, the comment will look like usual in the config
675           file.
676
677       $problem_lines
678           This variable is intended to be the placholder for the comment
679           lines describing any problems which might have been encountered
680           when trying to add the target into the configuration.  For host
681           templates it's normally not used and for those it's predefined as
682           the empty string.  For interface templates $problem_lines is prede‐
683           fined with the error description comments which cfgmaker normally
684           would use for rejected interfaces or as the empty string for
685           accepted interfaces.
686
687           It is possible to test against $problem_lines to find out if an
688           interface will be included or rejected but this is not recommended.
689           Test against $if_ok instead.
690
691       $separator_lines
692           This variable is the placeholder for the string to use as the sepa‐
693           rator between the code for individual targets.  The contents of
694           this variable is put after each target (so the lines will appear
695           after the end of the last target in the config as well).
696
697       Predefined Template Variables
698
699       All the variables below are available for interface templates to use.
700       For host templates, only those listed under "Host and System Variables"
701       are available.
702
703       For interface templates the variables listed under "Predefined Filter
704       Variables" are also available.
705
706       Host and System Variables
707
708       $router_name
709           This is the fully qualified name for the router.  It is affected by
710           the following items on the command line:  the router name itself
711           and --dns-domain.
712
713       $router_connect
714           This is the reference string for the router being polled.  It is on
715           the form community@router possibly followed by some snmp options.
716           It is affected by the following items on the command line:  the
717           router name itself, --community, --snmp-options and --dns-domain.
718           (There's no HTML escaped variant available)
719
720       $directory_name
721           This variable should contain the directory name as cfgmaker nor‐
722           mally would use as the value for the "Directory[]" directive.  The
723           value is determined by the --subdirs command line option.  If
724           --subdirs isn't specified $directory_name will be the empty string.
725           (There's no HTML escaped variant available)
726
727       $syscontact
728           This variable is the router's SNMP sysContact value.  (HTML escaped
729           variant: $html_syscontact)
730
731       $sysname
732           This variable is the router's SNMP sysName value.  (No HTML escaped
733           variant available)
734
735       $syslocation
736           This variable is the router's SNMP sysLocation value.  (HTML
737           escaped variant: $html_syslocation)
738
739       $sysdescr
740           This variable is the router's SNMP sysDescr value.  It is normally
741           not used by cfgmaker but might be useful in a template.  (HTML
742           escaped variant: $html_sysdescr)
743
744       Interface Target Related Variables
745
746       $target_name
747           This is what cfgmaker normally would use as the the name of the
748           target.  The target name is what is found within the square brack‐
749           ets, "[]", for target directives.  (There's no HTML escaped variant
750           available)
751
752       $if_ref
753           This the reference string for the interface.  It is expected to be
754           used in the "Target[xyz]" directive to distinguish what interface
755           to use.  The value of this variable is affected by the --ifref com‐
756           mand line option.  It is normally used together with $router_con‐
757           nect.  (There's no HTML escaped variant available)
758
759       $if_ok
760           This variable is true if the interface is going to be included into
761           the configuration file, otherwise false.  Don't test against other
762           variables such as $problem_lines to find out if an interface will
763           be rejected or not, use this $if_ok instead.
764
765       $default_target_lines
766           This variable contains all the target lines which cfgmaker by
767           default outputs for this interface.  It's useful if you want to
768           have the "standard target" but want to add some extra lines to it
769           by using a template.
770
771       By default cfgmaker uses the following directives for each target it
772       generates: Target[], SetEnv[], MaxBytes[], Title[], PageTop[] and if
773       there is any directory specified also the Directory[] directive.
774
775       To facilitate the creation of templates which generates target configs
776       which are similar to the default one, each of the above mentioned
777       directive lines have a corresponding variable containing the line as
778       cfgmaker would have output it by default.
779
780       Note that none of these have a HTML escaped variant, text in them is
781       HTML escaped where needed.  Also note that they do not have any newline
782       at the end.
783
784       $default_target_directive
785           This variable contains the default string for the Target[] direc‐
786           tive line.
787
788       $default_setenv_directive
789           This variable contains the default string for the SetEnv[] direc‐
790           tive line.
791
792       $default_directory_directive
793           This variable contains the default string for the Directory[]
794           directive line which means it is an empty string (with no newline)
795           if there's no directory.
796
797       $default_maxbytes_directive
798           This variable contains the default string for the MaxBytes[] direc‐
799           tive line.
800
801       $default_title_directive
802           This variable contains the default string for the Title[] directive
803           line.
804
805       $default_pagetop_directive
806           This variable contains the default string for the PageTop[] direc‐
807           tive lines.
808
809       Interface Network Configuration Variables
810
811       $if_ip
812           This variable should contain the IP-address of the interface, if
813           any has been assigned to it.  (There's no HTML escaped variant
814           available)
815
816       $ifindex
817           This variable is the SNMP ifIndex for the interface which per defi‐
818           nition always is an integer.  (There's no HTML escaped variant
819           available)
820
821       $if_index
822           Equivalent with $ifindex.
823
824       $if_eth
825           Contains the ethernet address of the interface, if any.  (There's
826           no HTML escaped variant available)
827
828       $if_speed
829           This variable is the speed in bytes/second (with prefixes).
830           (There's no HTML escaped variant available)
831
832       $if_speed_str
833           This variable is a cooked speed description which is either in bits
834           or bytes depending on wether or not the bits option is active and
835           also with the proper prefix for the speed (k, M, G etc).  (No HTML
836           escaped variant available)
837
838       $if_type_desc
839           This variable is a textual description of the interface type.
840           (HTML escaped variant: $html_if_type_desc)
841
842       $if_type_num
843           This variable the integer value corresponding to the interface type
844           (for a listing for the value for the more common interface types,
845           see the section DETAILS ON FILTERS above).  (No HTML escaped vari‐
846           ant available)
847
848       $if_dns_name
849           This is the DNS name for the interface.  (No HTML escaped variant
850           available)
851
852       Interface Name, Description and Alias Variables
853
854       It might seem confusing with both Name, Description and Alias in this
855       context and to some extent it is.  Name and Description are usually
856       supported on most equipment but how they are used varies, both between
857       manufacturers as well as between different cathegories of equipment
858       from the same manufacturer.  The Alias is at least supported by Cisco
859       IOS, and that variable contains whatever is used in the IOS statement
860       called "description" for the interface (not to be confused with the
861       SNMP variables for Description).
862
863       For better control from the command line consider $if_title_desc which
864       contents are controlled by the --if-descr command line option.
865
866       $if_snmp_descr
867           This variable should contain the "raw" description of the interface
868           as determined by the SNMP polling of the router.  (HTML escaped
869           variant: $html_if_snmp_descr)
870
871       $if_snmp_name
872           The "raw" name for the interface as provided by SNMP polling.
873           (HTML escaped variant: $html_if_snmp_name)
874
875       $if_snmp_alias
876           The "raw" ifAlias for the interface as provided by SNMP polling.
877           (HTML escaped variant: $html_if_snmp_alias)
878
879       $if_cisco_descr
880           The "raw" CiscolocIfDescr for the interface as provided by SNMP
881           polling.  (HTML escaped variant: $html_if_cisco_descr)
882
883       $if_description
884           This is the "cooked" description string for the interface, taking
885           into account the SNMP values found for the interface's RDescr,
886           ifAlias and CiscolocIfDescr.  (HTML escaped variant:
887           $html_if_description)
888
889       $if_title
890           The full string cfgmaker by default would have used for the Title[]
891           directive in the configuration as well as the content of the top‐
892           most H1 tag in the PageTop[].  Is composed by the contents of
893           $desc_prefix, $if_title_desc and $sysname.
894
895           As $if_title depends on $if_title_desc, it is possible to indi‐
896           rectly control $if_title by using the command line option
897           --if-descr.
898
899           (HTML escaped variant: $html_if_title)
900
901       $if_port_name
902           If the host is a Cisco Catalyst LAN switch, this variable is the
903           name of that port.  (No HTML escaped variant available)
904
905       $if_pp_port_name
906           If the host is a Nortel Passport LAN switch, this variable is the
907           name of that port.  (No HTML escaped variant available)
908
909       $desc_prefix
910           This variable is a prefix of the description of what the target is
911           to use in the "Title[]" directive and in the H1 section of the
912           "PageTop[]".  Default is "Traffic analysis for ".  (HTML escaped
913           variant: $html_desc_prefix)
914
915       $if_title_desc
916           This is the description of the interface normally used by cfgmaker
917           as part of the variable $if_title.  The latter is used as the full
918           string in the "Title[]" directove and the H1 section in the Page‐
919           Top[].
920
921           $if_title_desc is controlled by the command line option --if-descr
922           which indirectly controls the contents of $if_title
923
924           (HTML escaped variant: $html_if_title_desc)
925
926       Help Functions for Templates
927
928       The following functions exists to facilitate the writing of host and
929       interface templates.
930
931       html_escape(string)
932           html_escape() takes a string as an argument and returns a new
933           string where the following substitutions has been done:  the chars
934           "<", ">" and "&" are replaced by "&lt;", "&gt;" and "&amp;" and
935           that newlines embedded in the string are prepended with "<BR>" and
936           appended with a space character (newlines at the end of the string
937           are not touched).
938
939       oid_pick($router_connect,$v3opt,"oid1","oid2"...)
940           This function will try to poll each of the oids specified until it
941           is successful or has run out of oids. It will return the name of
942           the first oid that worked or undef if it is not successful
943
944       Example Template Files
945
946       Template Example 1: Eliminating Rejected Targets From Appearing
947
948       This template file generates exactly the same configuration code per
949       interface as cfgmaker does by default, with the exception that it elim‐
950       inates all lines (comments as well as config code) for an interface if
951       the interface happens to be rejected.
952
953        if(not $problem_lines)
954        {
955          $target_lines .= <<ECHO;
956
957        Target[$target_name]: $if_ref:$router_connect
958        SetEnv[$target_name]: MRTG_INT_IP="$if_ip" MRTG_INT_DESCR="$if_snmp_descr"
959        ECHO
960
961          if ($directory_name) {
962              $target_lines .= "Directory[$target_name]: $directory_name\n";
963          }
964
965          $target_lines .= <<ECHO;
966        MaxBytes[$target_name]: $if_speed
967        Title[$target_name]: $html_desc_prefix$html_if_title_desc -- $sysname
968        PageTop[$target_name]: <h1>$html_desc_prefix$html_if_title_desc -- $sysname</h1>
969                       <div id="sysdetails">
970                               <table>
971                                       <tr>
972                                               <td>System:</td>
973                                               <td>$sysname in $html_syslocation</td>
974                                       </tr>
975                                       <tr>
976                                               <td>Maintainer:</td>
977                                               <td>$html_syscontact</td>
978                                       </tr>
979                                       <tr>
980                                               <td>Description:</td>
981                                               <td>$html_if_description</td>
982                                       </tr>
983                                       <tr>
984                                               <td>ifType:</td>
985                                               <td>$html_if_type_desc ($if_type_num)</td>
986                                       </tr>
987                                       <tr>
988                                               <td>ifName:</td>
989                                               <td>$html_if_snmp_name</td>
990                                       </tr>
991        ECHO
992
993          $target_lines .= <<ECHO if defined $if_port_name;
994                                       <tr>
995                                               <td>Port Name:</td>
996                                               <td>$if_port_name</td>
997                                       </tr>
998        ECHO
999
1000          $target_lines .= <<ECHO if defined $if_pp_port_name;
1001                                       <tr>
1002                                               <td>Port Name:</td>
1003                                               <td>$if_pp_port_name</td>
1004                                       </tr>
1005        ECHO
1006
1007          $target_lines .= <<ECHO;
1008                                       <tr>
1009                                               <td>Max Speed:</td>
1010                                               <td>$if_speed_str</td>
1011                                       </tr>
1012        ECHO
1013
1014          $target_lines .= <<ECHO if $if_ip;
1015                                       <tr>
1016                                               <td>Ip:</td>
1017                                               <td>$if_ip ($if_dns_name)</td>
1018                                       </tr>
1019        ECHO
1020
1021          $target_lines .= <<ECHO;
1022                               </table>
1023                       </div>
1024        ECHO
1025        } else {
1026          $head_lines="";
1027          $problem_lines="";
1028          $target_lines="";
1029          $separator_lines="";
1030        }
1031
1032       Template Example 2: Simplier Version of Example 1
1033
1034       Example 1 was partly intended to demonstrate how to customize the gen‐
1035       eration of interface targets but also to provide a hint of how the
1036       variables are used in the "default" template which one could consider
1037       that cfgmaker normally uses.
1038
1039       If you're only intrested in the easiest way of entirely eliminating
1040       those reject interfaces, the template below would do the job as well by
1041       using $default_target_lines.
1042
1043        if($if_ok) {
1044         $target_lines = $default_target_lines;
1045        } else {
1046          $head_lines="";
1047          $problem_lines="";
1048          $target_lines="";
1049          $separator_lines="";
1050        }
1051
1052       Template Example 3: Creating CPU Targets for Hosts
1053
1054       Below is an example of a host template.
1055
1056        $head_lines .= <<ECHO;
1057        #---------------------------------------------------------------------
1058        ECHO
1059
1060        my $target_name = $router_name . ".cpu";
1061
1062        $target_lines .= <<ECHO;
1063
1064        YLegend[$target_name]: Percentage CPU load
1065        ShortLegend[$target_name]: %
1066        Legend1[$target_name]: CPU load in %
1067        Legend2[$target_name]:
1068        Legend3[$target_name]: Max Observed CPU load
1069        Legend4[$target_name]:
1070        LegendI[$target_name]: &nbsp;CPU Load:
1071        LegendO[$target_name]:
1072        WithPeak[$target_name]: ywm
1073        MaxBytes[$target_name]: 100
1074        Options[$target_name]: growright, gauge, nopercent
1075        Title[$target_name]: $router_name CPU load
1076        Target[$target_name]: 1.3.6.1.4.1.9.2.1.58.0&1.3.6.1.4.1.9.2.1.58.0:$router_connect
1077        PageTop[$target_name]: <h1>$router_name CPU load</h1>
1078                       <div>
1079                               <table>
1080                                       <tr>
1081                                               <td>System:</td>
1082                                               <td>$router_name in $html_syslocation</td>
1083                                       </tr>
1084                                       <tr>
1085                                               <td>Maintainer:</td>
1086                                               <td>$html_syscontact</td>
1087                                       </tr>
1088                                       <tr>
1089                                               <td>Description:</td>
1090                                               <td>$html_sysdescr</td>
1091                                       </tr>
1092                                       <tr>
1093                                               <td>Resource:</td>
1094                                               <td>CPU.</td>
1095                                       </tr>
1096                               </table>
1097                       </div>
1098        ECHO
1099

EXAMPLES

1101       The first example creates a config file for router.place.xyz:  the
1102       router has the community name public.  Interfaces get identified by
1103       their IP number.  Two global options get added to the config file.  The
1104       config file gets redirected to mrtg.conf.  The '\' signs at the end of
1105       the line mean that this command should be written on a single line.
1106
1107        cfgmaker --global "WorkDir: /home/tobi"           \
1108                 --global "Options[_]: growright,bits"    \
1109                 --ifref=ip                               \
1110                 public@router.place.xyz > mrtg.cfg
1111
1112       Note: if cfgmaker is not in your path, but you are in the directory
1113       where cfgmaker is stored, you can start it with ./cfgmaker
1114
1115       The next example creates a config file for four devices:
1116       router1.place.xyz, router2.place.xyz, switch1.place.xyz and
1117       switch2.place.xyz all with the community public.
1118
1119       The two routers will have --ifref set to descr whilst the two switches
1120       will use --ifref set to name.  Further the routers will use --ifdesc
1121       set to alias and switch1.place.xyz will use --ifdesc set to descr
1122       whilst switch2.place.xyz use name instead.
1123
1124       Finally, there will be two Options lines inserted in the configuration:
1125       One will be in the beginning, whilst the other will be inserted after
1126       the lines related to the two routers but before those lines related to
1127       the switches.
1128
1129        cfgmaker --global "WorkDir: /home/tobi"           \
1130                 --global "Options[_]: growright,bits"    \
1131                 --ifref=descr                            \
1132                 --ifdesc=alias                           \
1133                 public@router1.place.xyz                 \
1134                 public@router2.place.xyz                 \
1135                 --global "Options[_]: growright"         \
1136                 --ifref=name                             \
1137                 --ifdesc=descr                           \
1138                 public@switch1.place.xyz                 \
1139                 --ifdesc=name                            \
1140                 public@switch2.place.xyz > mrtg.cfg
1141
1142       The next example demonstrates how to use the --community,
1143       --snmp-options and --dns-domain to make the command line simpler.  All
1144       the equipment will use the community hidden, except for the ppp-server
1145       which use community access.  All equipment uses these SNMP options: 1s
1146       timeout, 1 retry and SNMP version 2 (backoff and port is unspecified
1147       which means they use the default values).  The exception again is the
1148       ppp-server which uses SNMP version 1.  Finally, all the equipment is
1149       part of the domain place.xyz, except for the ppp-server which is part
1150       of the domain remote.place.xyz.  Note that the latter is achieved sim‐
1151       ply by specifying the name of the ppp-server to be ppp-server.remote .
1152
1153        cfgmaker --global "WorkDir: /home/tobi"           \
1154                 --global "Options[_]: growright,bits"    \
1155                 --dns-domain=place.xyz                   \
1156                 --community=hidden                       \
1157                 --snmp-options=::1:1::2                  \
1158                 router1                                  \
1159                 router2                                  \
1160                 router3                                  \
1161                 router4                                  \
1162                 router5                                  \
1163                 switch1                                  \
1164                 switch2                                  \
1165                 switch3                                  \
1166                 switch4                                  \
1167                 switch5                                  \
1168                 switch6                                  \
1169                 switch7                                  \
1170                 access@ppp-server.remote:::::1 > mrtg.cfg
1171

SEE ALSO

1173       mrtg-reference
1174

AUTHOR

1176       Tobias Oetiker <tobi@oetiker.ch> and Jakob Ilves <jakob.ilves@ora‐
1177       cle.com>
1178

LICENSE

1180       GNU General Public License
1181
1183       Cfgmaker is Copyright 2000 by Tobias Oetiker <tobi@oetiker.ch>
1184
1185
1186
11872.16.2                            2008-05-16                       CFGMAKER(1)
Impressum