MRTG-REFERENCE(1) mrtg MRTG-REFERENCE(1) NNAAMMEE mrtg-reference - MRTG 2.17.7 configuration reference OOVVEERRVVIIEEWW The runtime behaviour of MRTG is governed by a configuration file. Run-of-the-mill configuration files can be generated with ccffggmmaakkeerr. (Check cfgmaker). But for more elaborate configurations some hand- tuning is required. This document describes all the configuration options understood by the mrtg software. SSYYNNTTAAXX MRTG configuration file syntax follows some simple rules: +o Keywords must start at the beginning of a line. +o Lines which follow a keyword line which start with a blank are appended to the keyword line +o Empty Lines are ignored +o Lines starting with a # sign are comments. +o You can add other files into the configuration file using IInncclluuddee:: _f_i_l_e Example: Include: base-options.inc If included files are specified with relative paths, both the current working directory and the directory containing the main config file will be searched for the files. The current working directory will be searched first. If the included filename contains an asterisk, then this is taken as a wildcard for zero or more characters, and all matching files are included. Thus, you can use this statement to include all files in a specified subdirectory. Example: Include: servers/*.cfg In this case, you should be very careful that your wildcard pattern does not find a match relative to the current working directory if you mean it to be relative to the main config file directory, since the working directory is checked for a match first (as with a normal Include directive). Therefore, use of something like '*/*' is discouraged. GGLLOOBBAALL KKEEYYWWOORRDDSS WWoorrkkDDiirr WorkDir specifies where the logfiles and the webpages should be created. Example: WorkDir: /usr/tardis/pub/www/stats/mrtg OOPPTTIIOONNAALL GGLLOOBBAALL KKEEYYWWOORRDDSS HHttmmllDDiirr HtmlDir specifies the directory where the html (or shtml, but we'll get on to those later) lives. NOTE: Workdir overrides the settings for htmldir, imagedir and logdir. Example: Htmldir: /www/mrtg/ IImmaaggeeDDiirr ImageDir specifies the directory where the images live. They should be under the html directory. Example: Imagedir: /www/mrtg/images LLooggDDiirr LogDir specifies the directory where the logs are stored. This need not be under htmldir directive. Example: Logdir: /www/mrtg/logs FFoorrkkss ((UUNNIIXX oonnllyy)) With system that supports fork (UNIX for example), mrtg can fork itself into multiple instances while it is acquiring data via snmp. For situations with high latency or a great number of devices this will speed things up considerably. It will not make things faster, though, if you query a single switch sitting next door. As far as I know NT can not fork so this option is not available on NT. Example: Forks: 4 EEnnaabblleeIIPPvv66 When set to yes, IPv6 support is enabled if the required libraries are present (see the mrtg-ipv6 manpage). When IPv6 is enabled, mrtg can talk to routers using SNMP over IPv6 and targets may be specified by their numeric IPv6 addresses as well as by hostname or IPv4 address. If IPv6 is enabled and the target is a hostname, mrtg will try to resolve the hostname to an IPv6 address and, if this fails, to an IPv4 address. Note that mrtg will only use IPv4 if you specify an IPv4 address or a hostname with no corresponding IPv6 address; it will not fall back to IPv4 if it simply fails to communicate with the target using IPv6. This is by design. Note that many routers do not currently support SNMP over IPv6. Use the _I_P_v_4_O_n_l_y per target option for these routers. IPv6 is disabled by default. Example: EnableIPv6: Yes EEnnaabblleeSSnnmmppVV33 When set to yes, uses the Net::SNMP module instead of the SNMP_SESSION module for generating snmp queries. This allows the use of SNMPv3 if other snmpv3 parameters are set. SNMPv3 is disabled by default. Example: EnableSnmpV3: yes RReeffrreesshh How many seconds apart should the browser (Netscape) be instructed to reload the page? If this is not defined, the default is 300 seconds (5 minutes). Example: Refresh: 600 IInntteerrvvaall How often do you call mrtg? The default is 5 minutes. If you call it less often, you should specify it here. This does two things: +o The generated HTML page contains the right information about the calling interval ... +o A META header in the generated HTML page will instruct caches about the time-to-live of this page ..... In this example, we tell mrtg that we will be calling it every 10 minutes. If you are calling mrtg every 5 minutes, you can leave this line commented out. Example: Interval: 10 Note that unless you are using rrdtool you can not set Interval to less than 5 minutes. If you are using rrdtool you can set interval in the format Interval: MM[:SS] Down to 1 second. Note though, setting the Interval for an rrdtool/mrtg setup will influence the initial creation of the database. If you change the interval later, all existing databases will remain at the resolution they were initially created with. Also note that you must make sure that your mrtg-rrd Web-frontend can deal with this kind of Interval setting. MMaaxxAAggee MRTG relies heavily on the real time clock of your computer. If the time is set to a wrong value, especially if it is advanced far into the future, this will cause mrtg to expire lots of supposedly old data from the log files. To prevent this, you can add a 'reasonability' check by specifying a maximum age for log files. If a file seems to be older, mrtg will not touch it but complain instead, giving you a chance to investigate the cause. Example: MaxAge: 7200 The example above will make mrtg refuse to update log files older than 2 hours (7200 seconds). WWrriitteeEExxppiirreess With this switch mrtg will generate .meta files for CERN and Apache servers which contain Expiration tags for the html and gif files. The *.meta files will be created in the same directory as the other files, so you will have to set "MetaDir ." and "MetaFiles on" in your apache.conf or .htaccess file for this to work NOTE: If you are running Apache-1.2 or later, you can use the mod_expire to achieve the same effect ... see the file htaccess.txt Example: WriteExpires: Yes NNooMMiibb22 Normally we ask the SNMP device for 'sysUptime' and 'sysName' properties. Some do not have these. If you want to avoid getting complaints from mrtg about these missing properties, specify the nomib2 option. An example of agents which do not implement base mib2 attributes are Computer Associates - Unicenter TNG Agents. CA relies on using the base OS SNMP agent in addition to its own agents to supplement the management of a system. Example: NoMib2: Yes SSiinngglleeRReeqquueesstt Some SNMP implementations can not deal with requests asking for multiple snmp variables in one go. Set this in your cfg file to force mrtg to only ask for one variable per request. Examples SingleRequest: Yes SSnnmmppOOppttiioonnss Apart from the per target timeout options, you can also configure the behaviour of the snmpget process on a more profound level. SnmpOptions accepts a hash of options. The following options are currently supported: timeout => $default_timeout, retries => $default_retries, backoff => $default_backoff, default_max_repetitions => $max_repetitions, use_16bit_request_ids => 1, lenient_source_port_matching => 0, lenient_source_address_matching => 1 The values behind the options indicate the current default value. Note that these settings OVERRIDE the per target timeout settings. A per-target SnmpOptions[] keyword will override the global settings. That keyword is primarily for SNMPv3. The 16bit request ids are the only way to query the broken SNMP implementation of SMC Barricade routers. Example: SnmpOptions: retries => 2, only_ip_address_matching => 0 Note that AS/400 snmp seems to be broken in a way which prevents mrtg from working with it unless SnmpOptions: lenient_source_port_matching => 1 is set. IIccoonnDDiirr If you want to keep the mrtg icons in someplace other than the working (or imagedir) directory, use the _I_c_o_n_D_i_r variable for defining the url of the icons directory. Example: IconDir: /mrtgicons/ LLooaaddMMIIBBss Load the MIB file(s) specified and make its OIDs available as symbolic names. For better efficiancy, a cache of MIBs is maintained in the WorkDir. Example: LoadMIBs: /dept/net/mibs/netapp.mib,/usr/local/lib/ft100m.mib LLaanngguuaaggee Switch output format to the selected Language (Check the _t_r_a_n_s_l_a_t_e directory to see which languages are supported at the moment. In this directory you can also find instructions on how to create new translations). Currently the following laguages are supported: big5 brazilian bulgarian catalan chinese croatian czech danish dutch eucjp french galician gb gb2312 german greek hungarian icelandic indonesia iso2022jp italian korean lithuanian malay norwegian polish portuguese romanian russian russian1251 serbian slovak slovenian spanish swedish turkish ukrainian Example: Language: danish LLooggFFoorrmmaatt Setting LogFormat to 'rrdtool' in your mrtg.cfg file enables rrdtool mode. In rrdtool mode, mrtg relies on rrrrddttooooll to do its logging. See mrtg-rrd. Example: LogFormat: rrdtool LLiibbAAdddd If you are using rrdtool mode and your rrrrddttooooll Perl module (RRDs.pm) is not installed in a location where perl can find it on its own, you can use LibAdd to supply an appropriate path. Example: LibAdd: /usr/local/rrdtool/lib/perl/ PPaatthhAAdddd If the rrrrddttooooll executable can not be found in the normal "PATH", you can use this keyword to add a suitable directory to your path. Example: PathAdd: /usr/local/rrdtool/bin/ RRRRDDCCaacchheedd If you are running RRDTool 1.4 or later with rrrrddccaacchheedd, then you can configure MRTG to take advantage of this for updates, either by using the RRDCACHED_ADDRESS environment variable, or by setting the RRDCached keyword in the configuration file. Note that, if both are set, the configuration file keyword will take precedence. Only UNIX domain sockets are fully supported prior to RRDTool v1.5, and you should note that using RRDCached mode will disable all Threshold checking normally done by MRTG. Appropriate warning messages will be printed if necessary. Examples: RRDCached: unix:/var/tmp/rrdcached.sock RRDCached: localhost:42217 RRuunnAAssDDaaeemmoonn The RunAsDaemon keyword enables daemon mode operation. The purpose of daemon mode is that MRTG is launched once and not repeatedly (as it is with cron). This behavior saves computing resourses as loading and parsing of configuration files happens only once on startup, and if the configuration file is modified. Using daemon mode MRTG itself is responible for timing the measurement intervals. Therfore its important to set the Interval keyword to an apropiate value. Note that when using daemon mode MRTG should no longer be started from cron as each new process runs forever. Instead MRTG should be started from the command prompt or by a system startup script. If you want mrtg to run under a particular user and group (it is not recomended to run MRTG as root) then you can use the ----uusseerr==_u_s_e_r___n_a_m_e and ----ggrroouupp==_g_r_o_u_p___n_a_m_e options on the mrtg commandline. mrtg --user=mrtg_user --group=mrtg_group mrtg.cfg Also note that in daemon mode restarting the process is required in order to activate changes in the config file. Under UNIX, the Daemon switch causes mrtg to fork into background after checking its config file. On Windows NT the MRTG process will detach from the console, but because the NT/2000 shell waits for its children you have to use this special start sequence when you launch the program: start /b perl mrtg mrtg.cfg You may have to add path information equal to what you add when you run mrtg from the commandline. Example RunAsDaemon: Yes Interval: 5 This makes MRTG run as a daemon beginning data collection every 5 minutes If you are daemontools and still want to run mrtg as a daemon you can additionally specify NoDetach: Yes this will make mrtg run but without detaching it from the terminal. If the modification date on the configuration file changes during operation, then MRTG will re-read the configuration on the next polling cycle. Note that sub-files which are included from the main configuration do not have their modification times monitored, only the top-level file is so checked. CCoonnvveerrssiioonnCCooddee Some devices may produce non-numeric values that would nevertheless be useful to graph with MRTG if those values could be converted to numbers. The ConversionCode keyword specifies the path to a file containing Perl code to perform such conversions. The code in this file must consist of one or more Perl subroutines. Each subroutine must accept a single string argument and return a single numeric value. When RRDtool is in use, a decimal value may be returned. When the name of one of these subroutines is specified in a target definition (see below), MRTG calls it twice for that target, once to convert the the input value being monitored and a second time to convert the output value. The subroutine must return an undefined value if the conversion fails. In case of failure, a warning may be posted to the MRTG log file using Perl's warn function. MRTG imports the subroutines into a separate name space (package MRTGConversion), so the user need not worry about pollution of MRTG's global name space. MRTG automatically prepends this package declaration to the user-supplied code. Example: Suppose a particular OID returns a character string whose length is proportional to the value to be monitored. To convert this string to a number that can be graphed by MRTG, create a file arbitrarily named "MyConversions.pl" containing the following code: # Return the length of the string argument sub Length2Int { my $value = shift; return length( $value ); } Then include the following global keyword in the MRTG configuration file (assuming that the conversion code file is saved in the mrtg/bin directory along with mrtg itself): ConversionCode: MyConversions.pl This will cause MRTG to include the definition of the subroutine Length2Int in its execution environment. Length2Int can then be invoked on any target by appending "|Length2Int" to the target definition as follows: Target[myrouter]: 1.3.6.1.4.1.999.1&1.3.6.1.4.1.999.1:public@mydevice|Length2Int See "Extended Host Name Syntax" below for complete target definition syntax information. SSeennddTTooGGrraapphhiittee If you want to send a copy of the collected data into a Graphite database in addition to storing it in the RRDfile, you can provide your Graphite database name/ip and port number here. This requires the Net::Graphite perl module which is available from CPAN. Examples: # If your Graphite receiver is running on the same host as the MRTG daemon and using the default port SendToGraphite: 127.0.0.1,2003 # If your Graphite receiver is running on 192.168.100.50 port 5000 SendToGraphite: 192.168.100.50,5000 # If your Graphite receiver is running on graphite.mydomain.com port 2003 SendToGraphite: graphite.mydomain.com,2003 Graphite's namespace has a number of restrictions on what characters are allowed. The SendToGraphite functionality makes an attempt to convert the MRTG target name and, if specified, the Legendi and Legendo values to Graphite namespace friendly values. Specifically, the following conversion rules apply: +o Underscores in the target_name are converted to periods which are Graphite namespace delimiters. +o Comma characters are not allowed so they are removed. +o The string "m2g" for MRTG to Graphite is prepended onto the Graphite namespace variable. Example MRTG target to Graphite namespace conversion: # Our MRTG target name from mrtg.cfg is as follows Target[switch_GigabitEthernet0_5]: \GigabitEthernet0/5:public1@switch:::::2 After the conversion you will end up with these Graphite namespace values m2g.switch.gigabitethernet0.5.in m2g.switch.gigabitethernet0.5.out Next is a more complicated example because Legendi and Legendo are in use to denote min and max voltage values that pertain to some APC UPS SNMP OIDs # Target, Legendi, and Legendo are specified in mrtg.cfg as follows Target[apc_minmaxline]: 1.3.6.1.4.1.318.1.1.1.3.2.3.0&1.3.6.1.4.1.318.1.1.1.3.2.2.0:public@apc: LegendI[apc_minmaxline]: upsAdvInputMinLineVoltage LegendO[apc_minmaxline]: upsAdvInputMaxLineVoltage After the conversion you will end up with these Graphite namespace values m2g.apc.minmaxline.upsAdvInputMinLineVoltage m2g.apc.minmaxline.upsAdvInputMaxLineVoltage If you don't see the data showing up in Graphite, chances are there are invalid characters in the namespace. To debug this, use the DEBUG=qw(log) directive at the top of the MRTG script to find out what is happening with the MRTG to Graphite namespace conversion. DEBUG=qw(log) will generate some output similar to what appears below 2016-10-13 06:08:39 -- --log: RRDs::update(/var/www/mrtg/switch/switch_gigabitethernet0_5.rrd, '1476356919:2738746035:2927936327') 2016-10-13 06:08:39 -- --log: graphite->send(m2g.switch.gigabitethernet0.5.in,2738746035,1476356919) 2016-10-13 06:08:39 -- --log: graphite->send(m2g.switch.gigabitethernet0.5.out,2927936327,1476356919) 2016-10-13 06:09:25 -- --log: RRDs::update(/var/www/mrtg/apc/apc_minmaxline.rrd, '1476356965:122:123') 2016-10-13 06:09:25 -- --log: graphite->send(m2g.apc.minmaxline.upsAdvInputMinLineVoltage,122,1476356965) 2016-10-13 06:09:25 -- --log: graphite->send(m2g.apc.minmaxline.upsAdvInputMaxLineVoltage,123,1476356965) If the MRTG log output looks reasonable, then take a look at Graphite's carbon-cache logs. PPEERR TTAARRGGEETT CCOONNFFIIGGUURRAATTIIOONN Each monitoring target must be identified by a unique name. This name must be appended to each parameter belonging to the same target. The name will also be used for naming the generated webpages, logfiles and images for this target. TTaarrggeett With the _T_a_r_g_e_t keyword you tell mrtg what it should monitor. The _T_a_r_g_e_t keyword takes arguments in a wide range of formats: Basic The most basic format is "port:community@router" This will generate a traffic graph for the interface 'port' of the host 'router' (dns name or IP address) and it will use the community 'community' (snmp password) for the snmp query. Example: Target[myrouter]: 2:public@wellfleet-fddi.domain If your community contains a "@" or a " " these characters must be escaped with a "\". Target[bla]: 2:stu\ pi\@d@router SNMPv2c If you have a fast router you might want to try to poll the ifHC* counters. This feature gets activated by switching to SNMPv2c. Unfortunately not all devices support SNMPv2c yet. If it works, this will prevent your counters from wraping within the 5 minute polling interval, since we now use 64 bit instead of the normal 32 bit. Example: Target[myrouter]: 2:public@router1:::::2 SNMPv3 As an alternative to SNMPv2c, SNMPv3 provides access to the ifHC* counters, along with encryption. Not all devices support SNMPv3, and you will also need the perl Net::SNMP library in order to use it. It is recommended that cfgmaker be used to generate configurations involving SNMPv3, as it will check if the Net::SNMP library is loadable, and will switch to SNMPv2c if v3 is unavailable. SNMP v3 requires additional authentication parameters, passed using the SnmpOptions[] per-target keyword. Example: Target[myrouter]: 2:router1:::::3 SnmpOptions[myrouter]: username=>'user1' noHC Not all routers that support SNMPv2 or SNMPv3 provide the ifHC* counters on every interface. The noHC[] per-target keyword signals that the low-speed counters ifInOctets and ifOutOctets should be queried instead. cfgmaker will automatically insert this tag if SNMPv2 or SNMPv3 is specified but the ifHC* counters are unavailable. Example: Target[myrouter]: #Bri0:router1:::::3 SnmpOptions[myrouter]: username=>'user1' noHC[myrouter]: yes Reversing Sometimes you are sitting on the wrong side of the link, and you would like to have mrtg report Incoming traffic as Outgoing and vice versa. This can be achieved by adding the '-' sign in front of the "Target" description. It flips the incoming and outgoing traffic rates. Example: Target[ezci]: -1:public@ezci-ether.domain Explicit OIDs You can also explicitly define which OID to query by using the following syntax 'OID_1&OID_2:community@router' The following example will retrieve error counts for input and output on interface 1. MRTG needs to graph two variables, so you need to specify two OID's such as temperature and humidity or error input and error output. Example: Target[myrouter]: 1.3.6.1.2.1.2.2.1.14.1&1.3.6.1.2.1.2.2.1.20.1:public@myrouter MIB Variables MRTG knows a number of symbolic SNMP variable names. See the file mibhelp.txt for a list of known names. One example are the ifInErrors and ifOutErrors. This means you can specify the above as: Example: Target[myrouter]: ifInErrors.1&ifOutErrors.1:public@myrouter SnmpWalk It may be that you want to monitor an snmp object that is only reachable by 'walking'. You can get mrtg to walk by prepending the OID with the string WWaaLLKK or if you want a particular entry from the table returned by the walk you can use WWaaLLKK_x where _x is a number starting from 0 (!). Example: Target[myrouter]: WaLKstrangeOid.1&WaLKstrangeOid.2:public@myrouter Target[myrouter]: WaLK3strangeOid.1&WaLK4strangeOid.2:public@myrouter SnmpGetNext A special case of an snmp object that is only reachable by 'walking' occurs when a single snmpgetnext will return the correct value, but snmpwalk fails. This may occur with snmp V2 or V3, as the snmpgetbulk method is used in these versions. You can get mrtg to use getnext instead of getbulk by prepending the OID with the string GGeeTTNNEEXXTT. Example: Target[myrouter]: GeTNEXTstrangeOid&GeTNEXTstrangeOid:public@myrouter Counted SNMP Walk In other situations, an snmpwalk is needed to count rows, but the actual data is uninteresting. For example, counting the number of mac-addresses in a CAM table, or the number of simultaneous dialup sessions. You can get MRTG to count the number of instances by prepending the OID with the string CCnnTTWWaaLLKK. The following will retrieve the number of simultaneous VOIP calls on some routers: Example: Target[myrouter]: CnTWaLK1.3.6.1.4.1.9.10.55.1.1.1.1.3&CnTWaLK1.3.6.1.4.1.9.10.55.1.1.1.1.3:public@myrouter Interface by IP Sometimes SNMP interface index can change, like when new interfaces are added or removed. This can cause all Target entries in your config file to become offset, causing MRTG to graphs wrong instances etc. MRTG supports IP address instead of ifindex in target definition. Then MRTG will query snmp device and try to map IP address to the current ifindex. You can use IP addresses in every type of target definition by adding IP address of the numbered interface after OID and separation char '/'. Make sure that the given IP address is used on your same target router, especially when graphing two different OIDs and/or interface split by '&' delimiter. You can tell cfgmaker to generate such references with the option ----iiffrreeff==iipp. Example: Target[myrouter]: /1.2.3.4:public@wellfleet-fddi.domain Target[ezci]: -/1.2.3.4:public@ezci-ether.domain Target[myrouter]: ifInErrors/1.2.3.4&ifOutErrors/1.2.3.4:public@myrouter Interface by Description If you can not use IP addresses you might want to use the interface names. This works similar to the IP address aproach except that the prefix to use is a \ instead of a / You can tell cfgmaker to generate such references with the option ----iiffrreeff==ddeessccrr. Example: Target[myrouter]: \My-Interface2:public@wellfleet-fddi.domain Target[ezci]: -\My-Interface2:public@ezci-ether.domain Target[myrouter]: ifInErrors\My-If2&ifOutErrors\My-If3:public@myrouter If your description contains a "&", a ":", a "@" or a " " you can include them but you must escape with a backlash: Target[myrouter]: \fun\:\ ney\&ddd:public@hello.router Interface by Name This is the only sensible way to reference the interfaces of your switches. You can tell cfgmaker to generate such references with the option ----iiffrreeff==nnaammee. Example: Target[myrouter]: #2/11:public@wellfleet-fddi.domain Target[ezci]: -#2/11:public@ezci-ether.domain Target[myrouter]: ifInErrors#3/7&ifOutErrors#3/7:public@myrouter If your description contains a "&", a ":", a "@" or a " " you can include them but you must escape with a backlash: Target[myrouter]: #\:\ fun:public@hello.router Note that the # sign will be interpreted as a comment character if it is the first non white-space character on the line. Interface by Ethernet Address When the SNMP interface index changes, you can key that interface by its 'Physical Address', sometimes called a 'hard address', which is the SNMP variable 'ifPhysAddress'. Internally, MRTG matches the Physical Address from the *.cfg file to its current index, and then uses that index for the rest of the session. You can use the Physical Address in every type of target definition by adding the Physical Address after the OID and the separation char '!' (analogous to the IP address option). The Physical address is specified as '-' delimited octets, such as "0a-0-f1-5-23-18" (omit the double quotes). Note that some routers use the same Hardware Ethernet Address for all of their Interfaces which prevents unique interface identification. Mrtg will notice such problems and alert you. You can tell cfgmaker to generate configuration files with hardware ethernet address references by using the option ----iiffrreeff==eetthh. Example: Target[myrouter]: !0a-0b-0c-0d:public@wellfleet-fddi.domain Target[ezci]: -!0-f-bb-05-71-22:public@ezci-ether.domain Target[myrouter]: 1.3.6.1.2.1.2.2.1.14!0a-00-10-23-44-51& *BREAK* 1.3.6.1.2.1.2.2.1.14!0a-00-10-23-44-51:public@myrouter Target[myrouter]: ifInErrors!0a-00-10-23-44-51& *BREAK* ifOutErrors!0a-00-10-23-44-51:public@myrouter Join the lines at *BREAK* ... Interface by Type It seems that there are devices that try to defy all monitoring efforts: the interesting interfaces have neither ifName nor a constant ifDescr not to mention a persistent ifIndex. The only way to get a constant mapping is by looking at the interface type, because the interface you are interested in is unique in the device you are looking at ... You can tell cfgmaker to generate such references with the option ----iiffrreeff==ttyyppee. Example: Target[myrouter]: %13:public@wellfleet-fddi.domain Target[ezci]: -%13:public@ezci-ether.domain Target[myrouter]: ifInErrors%13&ifOutErrors%14:public@myrouter Extended positioning of ifIndex There are OIDs that contain the interface index at some inner position within the OID. To use the above mentioned Interface by IP/Description/Name/Type methods in the target definition the keyword 'IndexPOS' can be used to indicate the position of ifIndex. If 'IndexPOS' is not used the ifIndex will be appended at the end of the OID. Example: Target[myrouter]: OID.IndexPOS.1/1.2.3.4&OID.IndexPOS.1/1.2.3.4:public@myrouter Replace OID by your numeric OID. Extended Host Name Syntax In all places where ``community@router'' is accepted, you can add additional parameters for the SNMP communication using colon- separated suffixes. You can also append a pipe symbol ( | ) and the name of a numeric conversion subroutine as described under the global keyword "ConversionCode" above. The full syntax is as follows: community@router[:[port][:[timeout][:[retries][:[backoff][:[version]]]]][|name] where the meaning of each parameter is as follows: port the UDP port under which to contact the SNMP agent (default: 161) The complete syntax of the port parameter is remote_port[!local_address[!local_port]] Some machines have additional security features that only allow SNMP queries to come from certain IP addresses. If the host doing the query has multiple interface, it may be necessary to specify the interface the query should come from. The port parameter allows the specification of the port of the machine being queried. In addition, the IP address (or hostname) and port of the machine doing the query may be specified. Examples: somehost somehost:161 somehost:161!192.168.2.4!4000 use 192.168.2.4 and port 4000 as source somehost:!192.168.2.4 use 192.168.2.4 as source somehost:!!4000 use port 4000 as source timeout initial timeout for SNMP queries, in seconds (default: 2.0) retries number of times a timed-out request will be retried (default: 5) backoff factor by which the timeout is multiplied on every retry (default: 1.0). version for SNMP version. If you have a fast router you might want to put a '2' here. For authenticated or encrypted SNMP, you can try to put a '3' here. This will make mrtg try to poll the 64 bit counters and thus prevent excessive counter wrapping. Not all routers support this though. SNMP v3 requires additional setup, see SnmpOptions[] for full details. Example: 3:public@router1:::::2 name the name of the subroutine that MRTG will call to convert the input and output values to integers. See the complete example under the global keyword "ConversionCode" above. Example: 1.3.6.1.4.1.999.1&1.3.6.1.4.1.999.2:public@mydevice:161::::2|Length2Int This would retrieve values from the OID 1.3.6.1.4.1.999.1 for input and .2 for output on mydevice using UDP port 161 and SNMP version 2, and would execute the user-defined numeric conversion subroutine Length2Int to convert those values to integers. A value that equals the default value can be omitted. Trailing colons can be omitted, too. The pipe symbol followed by the name parameter, if present, must come at the end. There must be no spaces around the colons or pipe symbol. Example: Target[ezci]: 1:public@ezci-ether.domain:9161::4 This would refer to the input/output octet counters for the interface with _i_f_I_n_d_e_x _1 on _e_z_c_i_-_e_t_h_e_r_._d_o_m_a_i_n, as known by the SNMP agent listening on UDP port 9161. The standard initial timeout (2.0 seconds) is used, but the number of retries is set to four. The backoff value is the default. Numeric IPv6 addresses If IPv6 is enabled you may also specify a target using its IPv6 address. To avoid ambiguity with the port number, numeric IPv6 addresses must be placed in square brackets. Example: Target[IPv6test]: 2:public@[2001:760:4::]:6161::4 External Monitoring Scripts If you want to monitor something which does not provide data via snmp you can use some external program to do the data gathering. The external command must return 4 lines of output: Line 1 current state of the first variable, normally 'incoming bytes count' Line 2 current state of the second variable, normally 'outgoing bytes count' Line 3 string (in any human readable format), telling the uptime of the target. Line 4 string, telling the name of the target. Depending on the type of data your script returns you might want to use the 'gauge' or 'absolute' arguments for the _O_p_t_i_o_n_s keyword. Example: Target[myrouter]: `/usr/local/bin/df2mrtg /dev/dsk/c0t2d0s0` Note the use of the backticks (`), not apostrophes (') around the command. If you want to use a backtick in the command name this can be done but you must escape it with a backslash ... If your script does not have any data to return but does not want mrtg to complain about invalid data, it can return 'UNKNOWN' instead of a number. Note though that only rrdtool is realy equipped to handle unknown data well. Multi Target Syntax You can also combine several target definitions in a mathematical expression. Any syntactically correct expression that the Perl interpreter can evaluate to will work. An expression could be used, for example, to aggregate both B channels in an ISDN connection or to calculate the percentage hard disk utilization of a server from the absolute used space and total capacity. Examples: Target[myrouter]: 2:public@wellfleetA + 1:public@wellfleetA Target[myrouter]: .1.3.6.1.4.1.999.1&.1.3.6.1.4.1.999.2:public@mydevice / .1.3.6.1.4.1.999.3&.1.3.6.1.4.1.999.4:public@mydevice * 100 Note that whitespace must surround each target definition in the expression. Target definitions themselves must not contain whitespace, except in interface descriptions and interface names, where each whitespace character is escaped by a backslash. MRTG automatically rounds the result of the expression to an integer unless RRDTool logging is in use and the gauge option is in effect for the target. Internally MRTG uses Perl's Math::BigFloat package to calculate the result of the expression with 40 digits of precision. Even in extreme cases, where, for example, you take the difference of two 64-bit integers, the result of the expression should be accurate. SNMP Request Optimization MRTG is designed to economize on its SNMP requests. Where a target definition appears more than once in the configuration file, MRTG requests the data from the device only once per round of data collection and uses the collected data for each instance of a particular target. Recognition of two target definitions as being identical is based on a simple string match rather than any kind of deeper semantic analysis. Example: Target[Targ1]: 1:public@CiscoA Target[Targ2]: 2:public@CiscoA Target[Targ3]: 1:public@CiscoA + 2:public@CiscoA Target[Targ4]: 1:public@CISCOA This results in a total of three SNMP requests. Data for 1:public@CiscoA and 2:public@CiscoA are requested only once each, and used for Targ1, Targ2, and Targ3. Targ4 causes another SNMP request for 1:public@CISCOA, which is not recognized as being identical to 1:public@CiscoA. MMaaxxBByytteess The maximum value either of the two variables monitored are allowed to reach. For monitoring router traffic this is normally the bytes per second this interface port can carry. If a number higher than _M_a_x_B_y_t_e_s is returned, it is ignored. Also read the section on _A_b_s_M_a_x for further info. The _M_a_x_B_y_t_e_s value is also used in calculating the Y range for unscaled graphs (see the section on _U_n_s_c_a_l_e_d). Since most links are rated in bits per second, you need to divide their maximum bandwidth (in bits) by eight (8) in order to get bytes per second. This is very important to make your unscaled graphs display realistic information. T1 = 193000, 56K = 7000, 10 MB Ethernet = 1250000, 100 MB Ethernet = 12500000. The _M_a_x_B_y_t_e_s value will be used by mrtg to decide whether it got a valid response from the router. If you need two different MaxBytes values for the two monitored variables, you can use MaxBytes1 and MaxBytes2 instead of MaxBytes. Example: MaxBytes[myrouter]: 1250000 TTiittllee Title for the HTML page which gets generated for the graph. Example: Title[myrouter]: Traffic Analysis for Our Nice Company OOPPTTIIOONNAALL PPEERR TTAARRGGEETT KKEEYYWWOORRDDSS PPaaggeeTToopp Things to add to the top of the generated HTML page. Note that you can have several lines of text as long as the first column is empty. Note that the continuation lines will all end up on the same line in the html page. If you want linebreaks in the generated html use the '\n' sequence. Example: PageTop[myrouter]: