SNMP Subagent Programmer's Guide

Nowaited Hello World Program
2-18 119728SNMP Subagent Programmer’s Guide
Programming Tutorials
Nowaited Hello World Program
This program enhances the Hello World program in two ways:
Hello World lets you change the value of the MIB object named helloPrintFreq.
However, the value of this object has no effect on the frequency at which Hello
World prints the message defined by helloOutputText; Hello World prints the
message only after processing a request from an SNMP manager. Nowaited Hello
World uses the value of helloPrintFreq to control the message printing rate by using
its value to define one of the parameters to the Guardian procedure AWAITIOX.
Hello World is idle until a request from an SNMP manager is received; its call to
mgmt_poll() blocks further processing until a message arrives from the NonStop
agent. Nowaited Hello World uses the management function mgmt_read_nowait()
so that it can call mgmt_poll() only when a message from the NonStop agent has
arrived. Using this nowaited approach lets a subagent perform other operations
while waiting for SNMP messages.
These files are related to Nowaited Hello World:
Functions
Invoke Nowaited Hello World by specifying the executable subagent name and the
NonStop agent process name:
RUN HELLONW /NAME $NWAIT/ $ZSNMP
Nowaited Hello World prints the message associated with the MIB object named
helloOutputText at the frequency associated with the MIB object named helloPrintFreq.
It also prints the message when it receives any request from an SNMP manager. This
subagent supports the same manager requests as Hello World:
Get and Set operations on helloOutputText
Get and Set operations on helloPrintFreq
Get operations on helloPrintCnt
A Set operation on helloPrintFreq results in the same trap generated by Hello World.
MIB
Nowaited Hello World uses the same MIB as Hello World. The MIB is shown in
Example 2-1, earlier in this section.
Logic
This subagent has exactly the same structure as Hello World, except for the addition of a
call to management function mgmt_read_nowait() and calls to two Guardian procedures:
AWAITIOX and FILE_GETINFO_.
hellonwc C source code
hellosmi MIB definition
hellonwm TACL routine