MIB file的開始和結(jié)束所有的MIB file的都以DEFINITIONS ::= BEGIN關(guān)鍵字開始,以END結(jié)束。我們所有添加的節(jié)點均應(yīng)在此之間。 XXX-TEST-MIB DEFINITIONS ::= BEGIN …… …… END
模塊引用區(qū)域在MIB開始關(guān)鍵字后,即是模塊引用區(qū)域,利用IMPORTS標(biāo)識,所有的模塊引用及群組的引用均使用FROM關(guān)鍵字說明其出處,引用使用分號(;)結(jié)束。 注:分號,英文全角分號。 在一個MIB file中,所有引用到的數(shù)據(jù)類型均應(yīng)有引用。 如: IMPORTS enterprises FROM RFC1155-SMI Integer32 FROM SNMPv2-SMI DisplayString FROM SNMPv2-TC; MIB核心部分(對象標(biāo)識,標(biāo)量節(jié)點,表格對象的定義)對象標(biāo)識對象標(biāo)識用關(guān)鍵字OBJECT IDENTIFIER聲明,它的主要功能是用來將一類功能的對象結(jié)合起來。展開或折疊此對象標(biāo)識即可展開或折疊此類功能的所有對象。 在ASN.1中,對象標(biāo)識符類型描述對象的抽象信息,MIB樹中的每一個標(biāo)號是用對象標(biāo)識符描述的。 例如: xxx OBJECT IDENTIFIER ::= {enterprises 22566}
xxx是一個子樹支,它定義在enterprises樹支下,“22566” 是子樹xxx在父樹enterprises下的一個唯一對象標(biāo)識符。 其編譯后的視圖為:
|
關(guān)鍵字 |
說明 |
備注 |
objectname |
被管理對象的名字 |
必須以小寫字母開頭 |
OBJECT-TYPE |
每一個葉子對象所必須的關(guān)鍵字 |
|
syntax |
被管理對象類型的關(guān)鍵字 |
Counter(計數(shù)) Gauge(標(biāo)準(zhǔn)) DisplayString(顯示字符串) Interger(整數(shù)) TimeTicks(時間戳) NetworkAddress(網(wǎng)絡(luò)地址) IpAddress(Ipv4地址) |
access |
該節(jié)點支持的訪問方式 |
read-only(只讀) read-write(讀寫) read-create(讀和創(chuàng)建) no-accessible(不可訪問) |
status |
該節(jié)點的狀態(tài) |
current (當(dāng)前的) deprecated (反對的) obsolete(廢棄的) |
description |
對被管理對象的功能、特征等進行描述的關(guān)鍵字 |
|
例如:
Xxxx OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"
"
::= { xxxx 1 }
表類型是一個特殊類型的聲明,表內(nèi)聲明的對象稱為列對象,表對象可以看作是一些標(biāo)量對象的集合。利用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) }
關(guān)鍵字 |
說明 |
備注 |
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}
END
|