MIB file的开始和结束
所有的MIB file的都以DEFINITIONS ::= BEGIN关键字开始,以END结束。我们所有添加的节点均应在此之间。
XXX-TEST-MIB DEFINITIONS ::= BEGIN
……
……
END
模块引用区域在MIB开始关键字后,即是模块引用区域,利用IMPORTS标识,所有的模块引用及群组的引用均使用FROM关键字说明其出处,引用使用分号(;)结束。
注:分号,英文全角分号。
在一个MIB file中,所有引用到的数据类型均应有引用。
如:
IMPORTS
enterprises
FROM RFC1155-SMI
Integer32
FROM SNMPv2-SMI
DisplayString
FROM SNMPv2-TC;
MIB核心部分(对象标识,标量节点,表格对象的定义) 对象标识对象标识用关键字OBJECT IDENTIFIER声明,它的主要功能是用来将一类功能的对象结合起来。展开或折叠此对象标识即可展开或折叠此类功能的所有对象。
在ASN.1中,对象标识符类型描述对象的抽象信息,MIB树中的每一个标号是用对象标识符描述的。
例如:
xxx OBJECT IDENTIFIER ::= {enterprises 22566}
xxx是一个子树支,它定义在enterprises树支下,“22566” 是子树xxx在父树enterprises下的一个唯一对象标识符。
其编译后的视图为:
标量节点
在每一个树支下,可以定义被管理资源的管理对象,其中一类是标量节点(直观地看象树叶的节点)。利用OBJECT-TYPE定义。其定义的句法如下:
objectname OBJECT-TYPE
SYNTAX (syntax)
MAX-ACCESS (access)
STATUS (status)
DESCRIPTION (description)
::= { ( parent ) ( number )
关键字
说明
备注
objectname
被管理对象的名字
必须以小写字母开头
OBJECT-TYPE
每一个叶子对象所必须的关键字
syntax
被管理对象类型的关键字
Counter(计数)
Gauge(标准)
DisplayString(显示字符串)
Interger(整数)
TimeTicks(时间戳)
NetworkAddress(网络地址)
IpAddress(Ipv4地址)
access
该节点支持的访问方式
read-only(只读)
read-write(读写)
read-create(读和创建)
no-accessible(不可访问)
status
该节点的状态
current (当前的)
deprecated (反对的)
obsolete(废弃的)
description
对被管理对象的功能、特征等进行描述的关键字
例如:
Xxxx OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"
"
::= { xxxx 1 }
表类型表类型是一个特殊类型的声明,表内声明的对象称为列对象,表对象可以看作是一些标量对象的集合。利用SEQUENCE和SEQUENCE OF定义表格和表格中的行, 通常来说,表格对象的名字后面加有后缀Table,行对象的名字后面加有后缀Entry。
其声明如下:
tablename OBJECT-TYPE
SYNTAX SEQUENCE OF Entrytype
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION (description)
:: ={ (parent) (number)}
entryname OBJECT-TYPE
SYNTAX Entrytype
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION description
INDEX { index list }
:: ={ (tablename) 1}
(Entrytype) :: =
SEQUENCE {
(column1) (column1type),
(column2) (column1type),
( columnN) (columnNtype) }
关键字
说明
备注
tablename
表格名
xxxxTable首字母小写
Entrytype
表对象名
XxxxEntry首字母大写
not-accessible
访问方式
此处必须是not-accessible
entryname
行名
和XxxxEntry名相同,首字母小写xxxxEntry
description
描述信息
源码如下:
XXX-TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS
enterprises
FROM RFC1155-SMI
Integer32
FROM SNMPv2-SMI
DisplayString
FROM SNMPv2-TC;
xxx OBJECT IDENTIFIER ::= {enterprises 22566}
zkClassInfoTable OBJECT IDENTIFIER ::= {xxx 1}
zkClassInfoTable2 OBJECT IDENTIFIER ::= {xxx 2}
zkClassInfoTable OBJECT-TYPE
SYNTAX SEQUENCE OF ZkClassInfoEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is test table.
"
::= {xxx 1}
zkClassInfoEntry OBJECT-TYPE
SYNTAX ZkClassInfoEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is teat entry.
"
INDEX {zkClassInfoIndex}
::= {zkClassInfoTable 1}
ZkClassInfoEntry ::= SEQUENCE {
zkClassInfoIndex Integer32,
zkClassInfoSex Integer32,
zkClassInfoAge Integer32,
zkCLassInfoName DisplayString,
zkClassInfoAddress DisplayString
}
zkClassInfoIndex OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 1}
zkClassInfoSex OBJECT-TYPE
SYNTAX Integer32 {
man(1),
woman(2)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 2}
zkClassInfoAge OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 3}
zkCLassInfoName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 4}
zkClassInfoAddress OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 5}
zkClassInfoTable2 OBJECT-TYPE
SYNTAX SEQUENCE OF ZkClassInfoEntry2
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is test table.
"
::= {xxx 2}
zkClassInfoEntry2 OBJECT-TYPE
SYNTAX ZkClassInfoEntry2
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is teat entry.
"
INDEX {zkClassInfoIndex}
::= {zkClassInfoTable2 1}
ZkClassInfoEntry2 ::= SEQUENCE {
zkClassInfoSex2 Integer32,
zkClassInfoAge2 Integer32,
zkCLassInfoName2 DisplayString,
zkClassInfoAddress2 DisplayString
}
zkClassInfoSex2 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry2 1}
END
XXX-TEST_MIB DEFINITIONS ::= BEGIN
IMPORTS
enterprises
FROM RFC1155-SMI
Integer32
FROM SNMPv2-SMI
DisplayString
FROM SNMPv2-TC;
xxx OBJECT IDENTIFIER ::= {enterprises 40256}
zkClassInfoTable OBJECT IDENTIFIER ::= {xxx 1}
zkClassInfoTable2 OBJECT IDENTIFIER ::= {xxx 2}
zkClassInfoTable OBJECT-TYPE
SYNTAX SEQUENCE OF ZkClassInfoEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is test table.
"
::= {xxx 1}
zkClassInfoEntry OBJECT-TYPE
SYNTAX ZkClassInfoEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is teat entry.
"
INDEX {zkClassInfoIndex}
::= {zkClassInfoTable 1}
ZkClassInfoEntry ::= SEQUENCE {
zkClassInfoIndex Integer32,
zkClassInfoSex Integer32,
zkClassInfoAge Integer32,
zkCLassInfoName DisplayString,
zkClassInfoAddress DisplayString
}
zkClassInfoIndex OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 1}
zkClassInfoSex OBJECT-TYPE
SYNTAX Integer32 {
man(1),
woman(2)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 2}
zkClassInfoAge OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 3}
zkCLassInfoName OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 4}
zkClassInfoAddress OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry 5}
zkClassInfoTable2 OBJECT-TYPE
SYNTAX SEQUENCE OF ZkClassInfoEntry2
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is test table.
"
::= {xxx 2}
zkClassInfoEntry2 OBJECT-TYPE
SYNTAX ZkClassInfoEntry2
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"
This is teat entry.
"
INDEX {zkClassInfoIndex}
::= {zkClassInfoTable2 1}
ZkClassInfoEntry2 ::= SEQUENCE {
zkClassInfoSex2 Integer32,
zkClassInfoAge2 Integer32,
zkCLassInfoName2 DisplayString,
zkClassInfoAddress2 DisplayString
}
zkClassInfoSex2 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"
"
::= {zkClassInfoEntry2 1}