SNMP 必备工具 :snmptranslate

SNMP 必备工具 :snmptranslate

NAME

snmptranslate - translate MIB OID names between numeric and textual forms
# 注释 :snmptranslate 命令可以在 MIB OID 在数字和文字名称之间进行转换

SYNOPSIS

snmptranslate [OPTIONS] OID [OID]...
# 注释 :snmptranslate 命令的格式是 snmptranslate [options] OID [oid]
# 注释 :从上面的格式可以看出,snmptranslate 一次可以转换多个 OID

DESCRIPTION

snmptranslate is an application that translates one or more SNMP object identifier values from their symbolic (textual) forms into their numerical forms (or vice versa).

OID is either a numeric or textual object identifier.

# 注释 :snmptranslate 是一个将一个或者多个 SNMP OID 从文字名称格式转换为数字格式的程序

# [oid] 可以是数字格式或者文字格式。

# 注意!snmptranslate 可以直接将数字格式的 oid 转换为名称格式,

# 但要把名称格式的 oid 转换为数字格式的 oid ,需要 -I 选项的配合。(参考 snmpcmd 和最后部分的例子)


OPTIONS

-D TOKEN[,...]
Turn on debugging output for the given TOKEN(s). Try ALL for extremely verbose output.
-h
Display a brief usage message and then exit.

-m MIBLIST
Specifies a colon separated list of MIB modules to load for this application. This overrides the environment variable MIBS.
The special keyword ALL is used to specify all modules in all directories when searching for MIB files. Every file whose name does not begin with "." will be parsed as if it were a MIB file.
-M DIRLIST
Specifies a colon separated list of directories to search for MIBs. This overrides the environment variable MIBDIRS.



-T TRANSOPTS

Provides control over the translation of the OID values. The following TRANSOPTS are available:


# 注释 :-T 选项用于控制转换的输出


-Td
Print full details of the specified OID.
# 注释 :-Td 表示输出该对象的详细定义,也就是在 MIB 中的定义,包括文字名称、所属 MIB、类型、状态、读写权限、描述信息,数字格式的 OID



-Tp
Print a graphical tree, rooted at the specified OID.

# 注释 :-Tp 用于打印从指定 OID 开始一直到该 OID 所属的 MIB 子树末端的树型结构信息
# 该选项很有用,如果要知道某个 MIB 或者某个表有什么内容,可以该选项

-Ta
Dump the loaded MIB in a trivial form.
# 注释 :-Ta 表示导出所有已经加载的 MIB 的数据,每个对象一行
# 默认情况下是导出所有已经加载的对象。
# 如果只想导出某个 MIB ,可以使用如 snmptranslate -Ta -M MTA-MIB 这样就只导出 MTA-MIB 下的信息
# 注释 :该选项其实和 -Tp 很像,只不过 -Tp 是树型结构的形式,而 -Ta 是一行一行的格式。
# 而且 -Tp 后面可以加 -m 或者某个 oid ,但 -Ta 后面加 <oid> 没有用

-Tl
Dump a labeled form of all objects.
# 注释 :-Tl 导出所有已经加载的 MIB 的对象,并且输出完整的 oid 路径,也是很有用的一个选项。
# 和 -Ta 相比,-Ta 只输出对象名,类型,值,而没有 OID 。而 -Tl 则除了这些外,还输出了完整的文字格式 OID 和 数字格式的 oid

-To
Dump a numeric form of all objects.
# 注释 :-To 则是导出已经加载的所有 MIB 的数字格式的 oid ,不含值和类型,仅仅有 oid 而已

-Ts
Dump a symbolic form of all objects.
# 注释 : -Ts 和 -To 相反,只输出文字格式的 OID 名称而已
# 以上两个选项,如果在只想知道某个 MIB 下有什么内容,而不关心具体的值时比较有用

-Tt
Dump a tree form of the loaded MIBs (mostly useful for debugging).
# 注释 :-Tt 和 -Tp 比较像,但相比 -Tp 来说不够清楚

-Tz
Dump a numeric and labeled form of all objects (compatible with MIB2SCHEMA format).
# 注释 ;-Tz 同时导出已经加载的 MIB 的所有对象的文字格式和数字格式的 OID
# 这也是一个比较有用的选项。

-V
Display version information for the application and then exit.
# 注释 :-V 选项显示版本信息并退出

-w WIDTH
Specifies the width of -Tp and -Td output. The default is very large.
# 注释 :-w 限制 -Tp 和 -Td 输出的最大宽度

In addition to the above options, snmptranslate takes the OID input (-I), MIB parsing (-M) and OID output (-O) options described in the INPUT OPTIONS, MIB PARSING OPTIONS and OUTPUT OPTIONS sections of the snmpcmd(1) manual page.


EXAMPLES
*
snmptranslate -On -IR sysDescr will translate "sysDescr" to a more qualified form:
system.sysDescr
# 注释 :如果要使 snmptranslate 把 symbol 格式的oid 转换为 numberic 格式的 oid ,需要使用 -IR 和 -On
# -IR 允许“随机”访问 MIB ,由 snmp 从 mib 库中查找和所给出的对象名匹配的 oid ,所以上面的例子可以直接写 sysDescr ,而不用写全路径
# 至于 -On 是输出数字格式的 oid ,这样就实现了把 symbol 格式的 oid 转换为 numberic 格式的 oid
*
snmptranslate -Onf -IR sysDescr will translate "sysDecr" to:
.iso.org.dod.internet.mgmt.mib-2.system.sysDescr
# 注释 :如果只是想找出 sysDescr 的 symbol 格式的 oid ,用 -Of
*
snmptranslate -Td -OS system.sysDescr will translate "sysDecr" into:
SNMPv2-MIB::sysDescr
sysDescr OBJECT-TYPE
  -- FROM SNMPv2-MIB
  -- TEXTUAL CONVENTION DisplayString
  SYNTAX OCTET STRING (0..255)
  DISPLAY-HINT "255a"
  MAX-ACCESS read-only
  STATUS current
  DESCRIPTION "A textual description of the entity. This
               value should include the full name and
               version identification of the system's
               hardware type, software operating-system,
               and networking software."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) 1 }
*
snmptranslate -Tp -OS system will print the following tree:
+--system(1)
   |
   +-- -R-- String    sysDescr(1)
   |        Textual Convention: DisplayString
   |        Size: 0..255
   +-- -R-- ObjID     sysObjectID(2)
   +-- -R-- TimeTicks sysUpTime(3)
   +-- -RW- String    sysContact(4)
   |        Textual Convention: DisplayString
   |        Size: 0..255
   +-- -RW- String    sysName(5)
   |        Textual Convention: DisplayString
   |        Size: 0..255
   +-- -RW- String    sysLocation(6)
   |        Textual Convention: DisplayString
   |        Size: 0..255
   +-- -R-- Integer   sysServices(7)
   +-- -R-- TimeTicks sysORLastChange(8)
   |        Textual Convention: TimeStamp
   |
   +--sysORTable(9)
      |
      +--sysOREntry(1)
         |
         +-- ---- Integer   sysORIndex(1)
         +-- -R-- ObjID     sysORID(2)
         +-- -R-- String    sysORDescr(3)
         |        Textual Convention: DisplayString
         |        Size: 0..255
         +-- -R-- TimeTicks sysORUpTime(4)
                  Textual Convention: TimeStamp
*
snmptranslate -Ta | head will produce the following dump:
dump DEFINITIONS ::= BEGIN
org ::= { iso 3 }
dod ::= { org 6 }
internet ::= { dod 1 }
directory ::= { internet 1 }
mgmt ::= { internet 2 }
experimental ::= { internet 3 }
private ::= { internet 4 }
security ::= { internet 5 }
snmpV2 ::= { internet 6 }
*
snmptranslate -Tl | head will produce the following dump:
.iso(1).org(3)
.iso(1).org(3).dod(6)
.iso(1).org(3).dod(6).internet(1)
.iso(1).org(3).dod(6).internet(1).directory(1)
.iso(1).org(3).dod(6).internet(1).mgmt(2)
.iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1)
.iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1)
.iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysDescr(1)
.iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysObjectID(2)
.iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysUpTime(3)
*
snmptranslate -To | head will produce the following dump
.1.3
.1.3.6
.1.3.6.1
.1.3.6.1.1
.1.3.6.1.2
.1.3.6.1.2.1
.1.3.6.1.2.1.1
.1.3.6.1.2.1.1.1
.1.3.6.1.2.1.1.2
.1.3.6.1.2.1.1.3
*
snmptranslate -Ts | head will produce the following dump
.iso.org
.iso.org.dod
.iso.org.dod.internet
.iso.org.dod.internet.directory
.iso.org.dod.internet.mgmt
.iso.org.dod.internet.mgmt.mib-2
.iso.org.dod.internet.mgmt.mib-2.system
.iso.org.dod.internet.mgmt.mib-2.system.sysDescr
.iso.org.dod.internet.mgmt.mib-2.system.sysObjectID
.iso.org.dod.internet.mgmt.mib-2.system.sysUpTime
*
snmptranslate -Tt | head will produce the following dump
  org(3) type=0
    dod(6) type=0
      internet(1) type=0
        directory(1) type=0
        mgmt(2) type=0
          mib-2(1) type=0
            system(1) type=0
              sysDescr(1) type=2 tc=4 hint=255a
              sysObjectID(2) type=1
              sysUpTime(3) type=8

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值