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