Title: How to Write an MIB
1How to Write an MIB
- The Monitoring Support for CUWiN Project
- Ray K. Lam
- May 21, 2007
2Why Learning to Write an MIB?
- We want to monitor CUWiN nodes
- TX power, CS threshold, RSSI,
- SNMP is the tool
- SNMP agents at the nodes
- SNMP manager at our central authority
- SNMP organizes data as MIB
- MIB management information base
3Outline
- Object Tree
- Structuring our data
- Defining Objects
- A simple example code
- More variations in the language
D. Mauro, K. Schmidt, Essential SNMP, Ch.
2.3-2.4 http//safari5.bvdep.com/0596000200/enettd
g-CHP-2-SECT-3
4The Object Tree
- Managed objects
- Data to be monitored
- Organized into a tree
- Root
- Root-Node
- Subtree
- Group of related data
- Data in both leaf and non-leaf nodes
5Object Identifier
- OID
- Object IDentifier
- Textual name
- iso.org.dod.internet
- Numerical string
- 1.3.6.1
6The 1.3.6.1 Subtree
- The internet subtree is our focus
- Directory branch
- Unused
- Mgmt branch
- Standard objects
- Experimental branch
- Testing and research
- We may use it
- Private branch
- For enterprises, e.g. Cisco
7Defining the Internet Subtree
- Internet OBJECT IDENTIFIER iso org(3)
dod(6) 1 - Directory OBJECT IDENTIFIER internet 1
- Mgmt OBJECT IDENTIFIER internet 2
- Experimental OBJECT IDENTIFIER internet 3
- Private OBJECT IDENTIFIER internet 4
8A Simple Example
- A stripped-down version of MIB-2
- See handout
- Usual structure
- Name of MIB
- Import other files
- Define OIDs
- Define actual objects
9Name and Imports
- Name of the MIB RFC1213-MIB
- Imports (like include)
- Datatypes and OIDs from other files
RFC1213-MIB DEFINITIONS BEGIN
IMPORTS mgmt, NetworkAddress, IpAddress,
Counter, Gauge, TimeTicks FROM
RFC1155-SMI OBJECT-TYPE FROM RFC 1212
10Defining OIDs
- mgmt uniquely defined by imports
- -- starts a comment
mib-2 OBJECT IDENTIFIER mgmt 1 --
groups in MIB-II system OBJECT IDENTIFIER
mib-2 1 interfaces OBJECT IDENTIFIER
mib-2 2 at OBJECT IDENTIFIER mib-2 3
ip OBJECT IDENTIFIER mib-2 4 icmp
OBJECT IDENTIFIER mib-2 5 tcp OBJECT
IDENTIFIER mib-2 6 udp OBJECT
IDENTIFIER mib-2 7 egp OBJECT
IDENTIFIER mib-2 8 transmission OBJECT
IDENTIFIER mib-2 10 snmp OBJECT
IDENTIFIER mib-2 11
11Defining Objects
ltnamegt OBJECT-TYPE SYNTAX ltdatatypegt ACCESS
lteither read-only, read-write, write-only, or
not-accessiblegt STATUS lteither mandatory,
optional, or obsoletegt DESCRIPTION "Textual
description describing this particular managed
object." ltUnique OID that defines this
objectgt
12Example Defining ifTable
- A table of network interfaces
- Object name ifTable (case sensitive)
- Datatype SEQUENCE OF IfEntry
- SEQUENCE OF is like array
- IfEntry to be defined
ifTable OBJECT-TYPE SYNTAX SEQUENCE OF
IfEntry ACCESS not-accessible STATUS
mandatory DESCRIPTION "A list of interface
entries. The number of entries is given by the
value of ifNumber." interfaces 2
13Example Defining ifTable
- Access type not-accessible
- Cannot query an agent for this objects value
- Status mandatory
- An agent must implement this object
- OID
- 1.3.6.1.2.1.2.2 / iso.org.dod.internet.mgmt.interf
aces.2
ifTable OBJECT-TYPE SYNTAX SEQUENCE OF
IfEntry ACCESS not-accessible STATUS
mandatory DESCRIPTION "A list of interface
entries. The number of entries is given by the
value of ifNumber." interfaces 2
14Defining the IfEntry Sequence
- Need to define IfEntry for ifTable
- ifTable is an object
- IfEntry is a SEQUENCE a special datatype
- SEQUENCE is a list of other datatypes
- Represents columnar fields in a table
IfEntry SEQUENCE ifIndex INTEGER, ..
. ifSpecific OBJECT IDENTIFIER
15Defining ifEntry
- ifEntry different from IfEntry
- ifEntry is an object
- IfEntry is a (user defined) datatype
- ifEntry defines a particular row in ifTable
- INDEX a unique key to identify a row
ifEntry OBJECT-TYPE SYNTAX IfEntry ACCESS
not-accessible STATUS mandatory DESCRIPTION
"An interface entry containing objects at the
subnetwork layer and below for a particular
interface." INDEX ifIndex ifTable 1
16Defining ifIndex
ifIndex OBJECT-TYPE SYNTAX INTEGER ACCESS
read-only STATUS mandatory DESCRIPTION "A
unique value for each interface. Its value
ranges between 1 and the value of ifNumber.
The value for each interface must remain
constant at least from one reinitialization of
the entity's network- management system to the
next reinitialization." ifEntry 1
17The Remaining Things
- Definition for each object in the IfEntry
sequence - Omitted in the handout
- The END clause
18More SMIv1 Datatypes
- INTEGER
- 32-bit number
- Often used to specify enumerated types
- 0 should NOT be used for enumeration
- Counter
- 32-bit number from 0 to 232 1
- Should only increase
- Wrap back to 0 when max is reached
19More SMIv1 Datatypes
- IpAddress
- Gauge
- 32-bit number from 0 to 232 1
- Can increase or decrease
- TimeTicks
- 32-bit number from 0 to 232 1
- Measures time in hundredths of a second
20SMIv2 Extensions
- New datatypes and changes
- OID of new branch
- iso.org.dod.internet.snmpV2.snmpModules.snmpMIB
.snmpMIBObjects
21Some New Datatypes
- Aliases (same as old datatypes)
- Integer32, Counter32, Gauge32
- Unsigned32
- 32-bit number from 0 to 232 1
- Counter64
- 64-bit version of Counter
22New Object Definition Fields
- UnitsParts
- Describe the unit, e.g. seconds, milliseconds
- MAX-ACCESS
- read-only, read-write, read-create,
not-accessible, accessible-for-notify - Either ACCESS or MAX-ACCESS should appear
ltnamegt OBJECT-TYPE SYNTAX ltdatatypegt
UnitsParts ltOptional, see abovegt MAX-ACCESS
ltSee abovegt STATUS ltSee abovegt DESCRIPTION
"Textual description describing this
particular managed object." AUGMENTS ltname
of tablegt ltUnique OID that defines this
objectgt
23New Object Definition Fields
- New keywords for STATUS
- Current, obsolete, and deprecated
- Current mandatory
- AUGMENTS
- Add a column to a table
ltnamegt OBJECT-TYPE SYNTAX ltdatatypegt
UnitsParts ltOptional, see abovegt MAX-ACCESS
ltSee abovegt STATUS ltSee abovegt DESCRIPTION
"Textual description describing this
particular managed object." AUGMENTS ltname
of tablegt ltUnique OID that defines this
objectgt
24Other New Features
- New textual conventions
- Not sure about this
- Refer to the reference
D. Mauro, K. Schmidt, Essential SNMP, Ch.
2.3-2.4 http//safari5.bvdep.com/0596000200/enettd
g-CHP-2-SECT-3
Writing the MIB is not the hard part designing
is.