SNMP Subagent Programmer's Guide
Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-15
Hello World Program
When the NonStop agent receives requests for a subagent from multiple managers, 
it processes them in turn when mgmt_poll() is called, in the order in which they 
were received.
If mgmt_poll() returns a value of less than 0, connection with the NonStop agent 
was lost.  In this case, the while loop terminates; otherwise, trap processing 
proceeds.
13. A test is performed to determine whether the value of the MIB object named 
helloPrintFreq was changed by the request just processed. If so, a trap is sent before 
mgmt_poll() is called again.
This subagent compares two variables (last_freq and helloPrintFreq) to determine 
whether the print frequency changed.  Alternatively, the value returned by 
mgmt_poll() could have been used to detect a change in print frequency. The 
mgmt_poll() function returns a 4-bit mask describing the SNMP operation 
performed. A value of 1 in the fourth bit indicates a Set request was processed. The 
subagent could have examined the value of the mask, then determined whether the 
MIB object changed was the print frequency by comparing the values of last_freq 
and helloPrintFreq.
14. The mgmt_trap() function generates a trap, in this case the trap described by the 
MIB object named helloFreqChange. This function expects two arguments:
•
The pointer returned from the call to mgmt_init_env() (mgmt_env).
•
A pointer to the structure generated by GDMOC when the trap definition was 
compiled. To name this structure, GDMOC adds the prefix TRAP_ to the trap 
name in the MIB definition. The name of the structure generated in this 
example is TRAP_helloFreqChange. 
The trap message sent contains the current value of the MIB object named 
helloPrintFreq.
15. The current value of the MIB object named helloOutputText is always printed.
16. The value of the MIB object named helloPrintCnt is incremented by 1.
17. Whenever mgmt_poll() fails, this loop, which terminates communication with the 
NonStop agent, is executed.
18. The mgmt_del_instance() function de-registers, from the run-time library,  MIB 
objects made manageable by a previous mgmt_new_instance() call. This function 
expects two arguments:
•
The pointer returned from the call to mgmt_init_env() (mgmt_env)
•
The pointer returned from the call to mgmt_new_instance() 
(mgmt_hello_handle)
19. The mgmt_term_env() function terminates communication with the NonStop agent. 
The only argument this function expects is the pointer identifying the session to 
terminate (mgmt_env).










