SNMP Subagent Programmer's Guide
Hello World Program
2-10 119728—SNMP Subagent Programmer’s Guide
Programming Tutorials
For example, you need to delete the extensions that map MIB objects to subagent
structures. In the case of the Hello World MIB, the following statements at the end of
the MIB must be deleted:
EXTEND OBJECT-TYPE helloOutputText
WITH C_VARIABLE helloText
IN C
EXTEND OBJECT-TYPE helloPrintFreq
WITH C_VARIABLE helloPrintFreq
IN C
EXTEND OBJECT-TYPE helloPrintCnt
WITH C_VARIABLE helloPrintCnt
IN C
In addition, the #include "typesmi" statement at the beginning of the Hello
World MIB must be deleted. Whether you need to add definitions of the standard
SNMP data types depends on the manager you use.
When installing a MIB on a manager station, consult the documentation for the target
manager to determine the exact MIB file modifications you need to make.
Compiling the MIB With GDMOC
When you compile a MIB definition with GDMOC, GDMOC creates a header file that
needs to be included in the global section of the subagent source code. The header file
contains all the structure and function definitions the run-time library needs to access
and use MIB object variables in various SNMP operations. As the next subsection
explains, these definitions are used when the subagent calls management functions. You
may want to print a copy of helloh, the GDMOC output file for the Hello World MIB, to
refer to while reviewing the subagent logic. Several of the structures defined in this file
need to be referenced in the subagent source code.
Logic
The subagent logic works together with the run-time library to respond to requests from
SNMP managers. In the simplest case, such as Hello World typifies, the subagent has to
only declare the variables that hold values for MIB objects and call the run-time library
when it is ready to initiate certain activities. The run-time library performs all the
SNMP message handling between the subagent and the NonStop agent. Refer to
Section 4, “Writing Subagent Logic,” for complete information about library functions.