MRTG 系列 :参数设定(中篇)

{ Posted on 星期六, 十二月 11, 2010 by Kaiser.XKw }
MRTG 系列 :参数设定(中篇)

ConversionCode

 

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.

 


 

Per target configuration

 

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.

 

# 注释 :下面开始介绍监测对象的配置。

 

# 由于一个 mrtg.cfg 文件中可以配置多个监测对象,为了区分不同的对象

 

# 每个被监测的对象都要有一个名称,所有和该对象相关的属性的定义都必须引用该名称,用于区分到底是定义那个对象的。

 

# 注释 :同时这个名称还被用于页面的生成、日志文件、

 


 

Target

With the Target keyword you tell mrtg what it should monitor. The Target keyword takes arguments in a wide range of formats:

 

# 注释 :首先就是 Target 选项了。它不仅为被监测对象分配一个名称,也指出了要监测对象的 oid

 

# Target 的格式是 :Target[<name>]:[parameters],其中 <name> 就是用于定义监测对象的名称

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[<name>]: <int_index>:<community>'@'<hostname | ip>

 

# 要注意,下面的例子中的 '2' 是 interface index ,所以要监测一个端口的信息前,要先知道该端口所对应的 interface index 是多少

 

# 在 Cisco 的设备上可以用 sh int index 来查看

 

Target[myrouter]: 2:public@wellfleet-fddi.ethz.ch

 

If your community contains a ``@'' or a `` '' these characters must be escaped with a ``\''.]

 

# 注释 :如果 community 中包含有 @ 字符或者空格,应该用 \ 进行转义

 

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:

 

# 注释 :有些情况下需要用到 snmp v2c 的对象,例如 snmp v1 的计数器只有 32 bit 长度,而 snmp v2c 的为 64 bit

 

# 对于一些百兆口或者千兆口,32 bit 是远远不够的。只能用 64 bit 的来表示

 

# 要明确表示该对象是 snmp v2c 的,则在主机名或者ip部分的后面加上 ":::::2" 这个字符串,注意共5个 ':' ,之间没有任何空格

 

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'

 


 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 之后的第一 ":" 加上一个 "-" 号,表示相反的意思

 

Target[ezci]: -1:public@ezci-ether.ethz.ch

 


 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.

 

# 注释 :MRTG 不仅可以监测接口,还可以使用 oid 来指定接口之外的其他监测对象

 

# 如果直接使用 oid ,需要同时给出两个 oid ,也就是 "<oid_1>&<oid_2>:<community>@<host | ip> 的格式

 

# 因为 MRTG 需要两个变量的值才能画图,所以你必须给出两个 oid


 

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:

 

# 注释 :MRTG 本身也知道一些 symbolic 格式的 snmp 对象。所以可以不用 oid 而直接用对象的名称来表示。

 

# 例如 ifInErrors 和 ifOutErrors

 

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 WaLK or if you want a particular entry from the table returned by the walk you can use WaLKx where x is a number starting from 0 (!).

Example:

 

# 注释 :如果有些对象是必须使用 snmpwalk 才能访问的,则可以在oid前面加上 "Walk" 的字符串,

 

# 如果要从某个表返回第几个记录,则用 "Walk<n>" 的方式

 

 Target[myrouter]: WaLKstrangeOid.1&WaLKstrangeOid.2:public@myrouter

 Target[myrouter]: WaLK3strangeOid.1&WaLK4strangeOid.2: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.

 

# 注释 :有时候,接口的 index 会改变,例如增加接口或者删除接口,这时候可以通过 ip 来标识,在内部 MRTG 会尝试将 ip 和 ifIndex 给映射起来。

 

# 要使用 ip ,格式是 :

 

#     -) "Target[<name>]: /<ip>:<community>@<host|ip>"

 

#     -) "Target[<name>]: <oid_1>/<ip_1>&<oid_2>/<ip_2>:<community>@<host|ip>"

 

You can tell cfgmaker to generate such references with the option --ifref=ip.

 

# 注释 :如果是使用 cfgmaker 命令,则为 --ifref=ip

 

Example:

 

Target[myrouter]: /1.2.3.4:public@wellfleet-fddi.ethz.ch

Target[ezci]: -/1.2.3.4:public@ezci-ether.ethz.ch

Target[myrouter]: 1.3.6.1.2.1.2.2.1.14/1.2.3.4&1.3.6.1.2.1.2.2.1.14/1.2.3.4:public@myrouter

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 --ifref=descr.

Example:

 

# 注释 :除了 ifIndex、ip之外,还可以用接口的描述信息来引用某个接口,不过和ip方式不同的是,“/” 换成了 “\" 字符

 

# 如果是使用 cfgmaker 命令,则为 --ifref=descr 选项


 

Target[myrouter]: \My-Interface2:public@wellfleet-fddi.ethz.ch

Target[ezci]: -\My-Interface2:public@ezci-ether.ethz.ch

Target[myrouter]: 1.3.6.1.2.1.2.2.1.14\My-Interface2&1.3.6.1.2.1.2.2.1.14\My-Interface3:public@myrouter

Target[myrouter]: ifInErrors\My-Interface2&ifOutErrors\My-Interface3: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 --ifref=name.

 

# 注释 :除了 ifIndex、ip、ifDescr 之外,还可以用接口名称来标识,对于交换机来说,这是唯一有意义的方式,

 

# 因为交换机的端口不存在ip,描述信息和 ifIndex 也比较麻烦,直接用 <module>/<port> 的方式最直接明了

 

# 和 ip、ifDescr 方式不同,用端口名称的方式使用

 

#     -) Target[<name>]: #<module>/<port>:<community>@<host|ip>

 

#     -) Target[<name>]: <oid_1>#<module>/<port>&<oid_2>#<module>/<port>:<community>@<host|ip>


 

Example:

 

Target[myrouter]: #2/11:public@wellfleet-fddi.ethz.ch

Target[ezci]: -#2/11:public@ezci-ether.ethz.ch

Target[myrouter]: 1.3.6.1.2.1.2.2.1.14#3/7&1.3.6.1.2.1.2.2.1.14#3/7:public@myrouter

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.

 

# 注释 :除了 ifIndex、ip、ifDescr、ifName 之外,还可以用 MAC 地址来标识一个地址。

 

# 补充 :接口的 MAC 地址可以用 ifPhysAddress 对象来查询

 

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.

 

# 注释:如果用 mac 地址来标识接口,可以用

 

#     -)Target[<name>]: !<mac>:<community>@<host|ip>

 

#     -)Target[<name>]: <oid_1>!<mac_1>&<oid_2>!<mac_2>:<community>@<host|ip>

 

You can tell cfgmaker to generate configuration files with hardware ethernet address references by using the option --ifref=eth.

 

# 注释 :如果用 cfgmaker 命令,则对应 --ifref=eth 选项

 

Example:

 

Target[myrouter]: !0a-0b-0c-0d:public@wellfleet-fddi.ethz.ch

Target[ezci]: -!0-f-bb-05-71-22:public@ezci-ether.ethz.ch

Target[myrouter]: 1.3.6.1.2.1.2.2.1.14!0a-00-10-23-44-51&!0a-00-10-23-44-51:public@myrouter

Target[myrouter]: ifInErrors!0a-00-10-23-44-51&ifOutErrors!0a-00-10-23-44-51:public@myrouter

 

 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 persistant 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 --ifref=type.

Example:


 

Target[myrouter]: %13:public@wellfleet-fddi.ethz.ch

Target[ezci]: -%13:public@ezci-ether.ethz.ch

Target[myrouter]: 1.3.6.1.2.1.2.2.1.14%13&1.3.6.1.2.1.2.2.1.14%14:public@myrouter

Target[myrouter]: ifInErrors%13&ifOutErrors%14:public@myrouter

 

 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:

 

# 注释 :在 Target 语句的 "<community>@<host|ip>" 部分,可以对 host|ip 部分再进一步的设置。

 

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)

 

# 注释 :<port> 设置 MRTG 连接 Agent 的那个 UDP 端口,默认是 161

timeout

initial timeout for SNMP queries, in seconds (default: 2.0)

 

# 注释 :<timeout> 设置 SNMP 操作第一次的超时时间,默认是2秒

retries

number of times a timed-out request will be retried (default: 5)

 

# 注释 :<retries> 设置超时重试的次数,默认为5次

backoff

factor by which the timeout is multiplied on every retry (default: 1.0).

 

# 注释 :backoff 设置超时时间的因子,也就是说每次重试间隔的时间等于 <timeout>*<backoff>

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.

 

# 注释 :version 表示默认使用什么版本

 

Example:

 

3:public@router1:::::2

 

# 注释 :我们在前面提到如何使用 snmp v2,要在 Target 后加上 ":::::2" ,其中的5个 ":" 就是代表 ":"port":"timeout":"retires":"backoff":"version 的5个 “:”

 

 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.

 

# 注释 :<name> 部分就是 MRTG 用于将输入/输出的值转换我也整数的脚本名称

 

# 具体见 “ConversionCode” 语句

 

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.

 

# 注释 :上面的语句表示将 .13.6.1.4.1.999.1 的值作为输入,1.3.6.1.4.1.999.2 的值作为输出,并使用 snmp v2 。

 

# 然后把这两个值通过脚本 Length2Int 转换为整数


 

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.

 

# 注释 :如果某个值等于默认值,可以省略,只用 ":" 表示, 同时,最后一个 ":" 也可以省略

 

# 如果用到 subroutine ,则必须放在最后

 

# 不管是 ":" 还是 “|” 之间都没有空格

 

Example:

 

 Target[ezci]: 1:public@ezci-ether.ethz.ch:9161::4

 

This would refer to the input/output octet counters for the interface with ifIndex 1 on ezci-ether.ethz.ch, 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:

 

# 注释 :如果要监测的对象并不在 snmp mib 总,则要通过脚本来实现。

 

# 这个外部的脚本必须返回4行输出,分别代表 :

Line 1

current state of the first variable, normally 'incoming bytes count'

 

# 注释 :第一行代表监测对象第一个属性的当前状态,也被 MRTG 作为 “流入的字节数” 看待

Line 2

current state of the second variable, normally 'outgoing bytes count'

 

# 注释 :第二行代表监测对象第二个属性的当前状态,也被 MRTG 作为 “流出的字节数” 看待

Line 3

string (in any human readable format), telling the uptime of the target.

 

# 注释 :第三行是一个字符串,告诉监测对象的 Uptime

Line 4

string, telling the name of the target.

 

# 注释 :第四行也就是字符串,告诉 MRTG 被监测对象的名称

 

# 问题 :外部脚本输出的4行信息中,第1和2行是否应该为数字格式?如果中间存在空行可以吗?

 

Depending on the type of data your script returns you might want to use the 'gauge' or 'absolute' arguments for the Options keyword.

 

# 注释 :同时可以针对脚本返回的数据类型设定 Options 语句中的 "gauge" 或者 "absolute" 参数


 

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.

 

# 注释 :如果要使用脚本,则连同脚本名称和参数都必须用 ` ` 括起来

 

# 如果命令中含有 “`” ,应该用 “\" 进行转义

 

# 补充 :如果脚本什么也不返回,又不想 MRTG 报错,可以返回“UNKNOWN” 字符串,不过只有 rrdtool 才能较好地处理未知数据


 


 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.

 

# 注释 :还有一种情况就是在 Target 行需要用到数学计算。

 

# 例如计算整个磁盘的空间利用率,而不仅仅是单个分区的利用率。

 

# 可以在 Target 行使用 "+" , "-" , "*" , "/" 来连接数学表达式的两个部分。

 

# 但要注意,数学符号的两边必须有空格,否则会引起混乱,例如 "/" 既可以做为除号,也可以用于标识端口 /<ip>

 

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.

 

# 注释 :MRRTG 对于表达式的值会自动四舍五入,并精确到小数点后40位,除非使用了 RRDTool 日志,或者 Target 的值类型为 Gauge 。

 

# MRTG 在内部使用 Perl 的 Match::BigFloat 软件包来计算表达式的值


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.

 

# 注释 :MRTG 会尽量的节省发送 SNMP 请求的次数。

 

# 例如在 mrtg.cfg 中如果重复出现一个对象,则 MRTG 只会在一个 Interval 内对该对象查询1次,

 

# 而不是对于该对象每次出现都执行一次 snmp 请求。同时该值就应用于配置文件中该对象出现的所有位置

 

# 注释 :MRTG 只是通过简单的字符串比较来发现配置文件中一个对象是否重复出现,并没有其他的手段

 

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.

 

# 注释 :在上面的例子中,Targ1 和 Targ2 的 "1:public@CiscoA" 相同, Targ2 和 Targ3 的 "2:public@CiscoA" 相同

 

# 所以 MRTG 在取得 Targ1 和 Targ2 的值后,在计算 Targ3 时就不再查询 "1:public@CiscoA" 和 "2:public@CiscoA" 了

 

# 不过 Targ4 的 "1:public@Cisc0A" 和 “1:public@CiscoA" 不同,所以 MRTG 会发送一个 snmp 查询

 


 

MaxBytes

 

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 MaxBytes is returned, it is ignored. Also read the section on AbsMax for further info. The MaxBytes value is also used in calculating the Y range for unscaled graphs (see the section on Unscaled).

 

# 注释 :可以为监测对象的两个属性定义最大值。单位是字节

 

# 如果 snmp 查询返回的值大于 MaxBytes 的值,则被忽略。

 

# MaxBytes 同样用于画图时的 Y 轴。

 

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 MaxBytes value will be used by mrtg to decide whether it got a valid response from the router.

 

# 注释 :在计算时要注意单位的换算。

 

# 10MB= 10*1000*1000/8=1250000

 

# 100MB= 100*1000*1000/8=12500000

 

# 1GB= 1000*1000*1000/8=125000000

 

If you need two different MaxBytes values for the two monitored variables, you can use MaxBytes1 and MaxBytes2 instead of MaxBytes.

Example:

 

# 注释 :可以对两个属性值定义不同的 MAX 值,分别用 MaxBytes1 和 MaxBytes2 来表示

 

MaxBytes[myrouter]: 1250000

 


 

Title

 

Title for the HTML page which gets generated for the graph.

Example:

 

# 注释 :Title 用于指定生成的 HTML 页面的标题

 

Title[myrouter]: Traffic Analysis for Our Nice Company

 


 

Optional per target keywords

 

# 注释 :下面这些都是每个 Target 可选的选项

 

PageTop

 

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.

 

# 注释 :PageTop 是用于在生成的 HTML 页面的顶部添加一些信息。

 

# 不像 Title ,PageTop 可以多行,只要后续的行以空白开头就可以了,就像 sendmail 的一样, MRTG 会把它当成是上一行的继续。

 

# 如果要输出换行,可以使用 "\n" 表示

        

Example:

 

PageTop[myrouter]: <H1>Traffic Analysis for ETZ C95.1</H1>

  Our Campus Backbone runs over an FDDI line \n

  with a maximum transfer rate of 12.5 megabytes per

  Second.


 


 

RouterUptime

 

In cases where you calculate the used bandwidth from several interfaces you normaly don't get the router uptime and router name displayed on the web page.

If these interfaces are on the same router and the uptime and name should be displayed you have to specify its community and address again with the RouterUptime keyword.

 

# 注释 :如果在 Target 使用了表达式,MRTG 不会显示该 Target 的 Uptime 和 Name

 

# 如果 Target 中的接口都是在同一个 Agent 上的,可以用  RouterUptime 来告诉 MRTG

 

# 用给定的 community 查询那个设备就可以得到真正的 Uptime 和 Name


 

Example:

 

Target[kacisco.comp.edu]: 1:public@194.64.66.250 + 2:public@194.64.66.250

RouterUptime[kacisco.comp.edu]: public@194.64.66.250

 

 

 RouterName

 

If the default name of the router is incorrect/uninformative, you can use RouterName to specify a different OID on either the same or a different host.

A practical example: sysName on BayTech DS72 units always display ``ds72'', no matter what you set the Unit ID to be. Instead, the Unit ID is stored at 1.3.6.1.4.1.4779.1.1.3.0, so we can have MRTG display this instead of sysName.

Example:

RouterName[kacisco.comp.edu]: 1.3.6.1.4.1.4779.1.1.3.0

 

A different OID on a different host can also be specified:

 

RouterName[kacisco.comp.edu]: 1.3.6.1.4.1.4779.1.1.3.0:public@194.64.66.251

 

 

 MaxBytes1

Same as MaxBytes, for variable 1.

 

MaxBytes2

Same as MaxBytes, for variable 2.

 


 

IPv4Only

Many IPv6 routers do not currently support SNMP over IPv6 and must be monitored using IPv4. The IPv4Only option forces mrtg to use IPv4 when communicating with the target, even if IPv6 is enabled. This is useful if the target is a hostname with both IPv4 and IPv6 addresses; without the IPv4Only keyword, monitoring such a router will not work if IPv6 is enabled.

 

If set to no (the default), mrtg will use IPv6 unless the target has no IPv6 addresses, in which case it will use IPv4. If set to yes, mrtg will only use IPv4.

Note that if this option is set to yes and the target does not have an IPv4 address, communication with the target will fail.

This option has no effect if IPv6 is not enabled.

Example:

 

Target[v4onlyrouter_1]: 1:public@v4onlyrouter

IPv4Only[v4onlyrouter_1]: Yes

 


 

SnmpOptions (V3)

SNMPv3 requires a fairly rich set of options. This per-target keyword allows access to the User Security Model of SNMPv3. Options are listed in the same syntax as a perl hash.

Security Modes

SNMPv3 has three security modes, defined on the device being polled. For example, on Cisco routers the security mode is defined by the snmp-server group global configuration command.

NoAuthNoPriv

Neither Authentication nor Privacy is defined. Only the Username option is specified for this mode.

Example:

SnmpOptions[myrouter]: username=>'user1'

AuthNoPriv

Uses a Username and a password. The password can be hashed using the snmpkey application, or passed in plain text along with the ContextEngineID

Example:

SnmpOptions[myrouter]: username=>'user1',authpassword=>'example',

  contextengineid=>'80000001110000004000000'

Priv

Both Authentication and Privacy is defined. The default privacy protocol is des.

Example: SnmpOptions[myrouter]: authkey=>'0x1e93ab5a396e2af234c8920e61cfe2028072c0e2', authprotocol=>'sha',privprotocol=>'des',username=>'user1', privkey=>'0x498d74940c5872ed387201d74b9b25e2'

snmp options

The following option keywords are recognized:

username

The user associated with the User Security Model

contextname

An SNMP agent can define multiple contexts. This keyword allows them to be polled.

contextengineid

A unique 24-byte string identifying the snmp-agent.

authpassword

The plaintext password for a user in either AuthNoPriv or Priv mode.

authkey

A md5 or sha hash of the plain-text password, along with the engineid. Use the snmpkey commandline program to generate this hash, or use Net::SNMP::Security::USM in a script.

authprotocol {sha|md5}

The hashing algorithm defined on the SNMP client. Defaults to md5.

privpassword

A plaintext pre-shared key for encrypting snmp packets in Priv mode.

privkey

A hash of the plain-text pre-shared key, along with the engineid. Use the snmpkey commandline program to generate this hash, or use Net::SNMP::Security::USM in a script.

privprotocol {des|3desede|aescfb128|aescfb192|aescfb256}

Specifies the encryption method defined on the snmp agent. The default is des.

 



No Response to "MRTG 系列 :参数设定(中篇)"