SNMP Subagent Programmer's Guide
Introduction to Subagent Programming
SNMP Subagent Programmer’s Guide—119728 1-5
Subagent Development Cycle
Defining Objects
If you believe that it is feasible, possible, and practical to build a subagent, you need to
make some decisions about each object you want to make accessible to a manager.
Determine the objects to make accessible and identify how each object is to be viewed
from a manager’s perspective:
Which objects need to be modeled as tables? As scalar variables?
Should I let managers retrieve object values? Change them? Which ones?
Do I need to generate traps? What should they look like?
How should the objects be formatted?
Writing the MIB Definition
The next step is to encode your object decisions in a formal MIB definition. The Toolkit
supports the standard concise MIB encoding conventions for this purpose. For example,
the following MIB definition is for a MIB object used by one of the sample subagents
discussed in Section 2, “Programming Tutorials”:
helloPrintCnt OBJECT-TYPE
SYNTAX Counter
ACCESS read-only
STATUS mandatory
DESCRIPTION
"A running count of the number of times the
helloOutputText message has been printed to
the console."
::= { hello 3 }
This object, named helloPrintCnt, is a counter that a manager can only perform SNMP
Get operations for, because it has read-only access. The last line of the definition
identifies where in the name hierarchy this object resides. Refer to Section 3, “Writing
and Compiling MIBs,” for information about the meaning of and encoding conventions
for MIBs and their objects. Section 3, “Writing and Compiling MIBs,” also describes
how to register your MIB definition with the Internet Assigned Numbers Authority
(IANA).
Designing the Subagent
Some subagents are implemented as stand-alone processes, and others are integrated
into new or existing applications. Figure 1-4 illustrates some of the major alternatives.
Which style to adopt for a particular subagent is influenced by many factors, including
ease of implementation, scope of control, and packaging.