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

NAME

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

SYNOPSIS

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

OPTIONS

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

DESCRIPTION

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

EXAMPLES

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

SEE ALSO

1195       mrtg-reference
1196

AUTHOR

1198       Tobias Oetiker <tobi@oetiker.ch> and Jakob Ilves
1199       <jakob.ilves@oracle.com>
1200

LICENSE

1202       GNU General Public License
1203
1205       Cfgmaker is Copyright 2000 by Tobias Oetiker <tobi@oetiker.ch>
1206
1207
1208
12092.17.10                           2022-01-19                       CFGMAKER(1)
Impressum