SNMP Subagent Programmer's Guide

Hello World Program
2-8 119728SNMP Subagent Programmer’s Guide
Programming Tutorials
Object Identifiers
Object identifiers define the SNMP hierarchy in which the MIB resides. They also
identify objects in the MIB. In the case of the Hello World MIB, named hello, the
hierarchy looks like this:
iso (1)
org (3)
dod (6)
internet (1)
private (4)
enterprises (1)
peer (442)
peer-demos (2)
hello (1)
helloOutputText (1)
helloPrintFreq (2)
helloPrintCnt (3)
SNMP conventions require that every MIB and object within it have a unique object
identifier whose components start with “iso” and terminate with the object itself.
Each MIB object definition finishes with an identification of the subtree in which the
object resides and a unique number. For example, the third object in the hello subtree,
helloPrintCnt, is identified like this:
::= { hello 3 }
Object Access
Another important aspect of MIB object definitions is the ACCESS clause. This clause
determines how an SNMP manager can interact with an object. In this example, two of
the objects (helloOutputText and helloPrintFreq) can be both retrieved and changed;
therefore, they are assigned the read-write attribute value. The object named
helloPrintCnt can be read but not changed by the manager; so it is assigned the read-
only attribute value.
Traps
A trap definition in a MIB identifies the type of trap and MIB objects to include in a trap
message. In the case of this MIB, only one MIB object, helloPrintFreq, is included in
the trap:
helloFreqChange TRAP-TYPE
ENTERPRISE hello
VARIABLES { helloPrintFreq }
DESCRIPTION
"A helloFreqChange trap signifies that the
sending hello world entity has had its
'helloPrintFreq' variable modified."
::= 0