Difference between revisions of "Template:FAQ:Coding 09"

From Net-SNMP Wiki
Jump to: navigation, search
 
m (5.4 release synchronisation)
Line 1: Line 1:
 +
<!-- NB:
 +
  There is a mismatch between the template numbering
 +
  for this entry, and the FAQ entries that refer to it.
 +
  This follows a review of the entries in the
 +
  Coding section.
 +
-->
 
The answer to that heavily depends on the characteristics of the
 
The answer to that heavily depends on the characteristics of the
 
MIB objects being implemented.  Of the handler-based table frameworks,
 
MIB objects being implemented.  Of the handler-based table frameworks,
Line 24: Line 30:
  
 
For implementing a group of scalar objects, then the choice is
 
For implementing a group of scalar objects, then the choice is
simple - use <CODE>'mib2c.scalar.conf'</CODE>. Similarly, for generating traps
+
simple - use <CODE>'mib2c.scalar.conf'</CODE>.
 +
 
 +
Similarly, for generating traps
 
or informs, use <CODE>'mib2c.notify.conf'</CODE>.
 
or informs, use <CODE>'mib2c.notify.conf'</CODE>.

Revision as of 23:30, 28 December 2006

The answer to that heavily depends on the characteristics of the MIB objects being implemented. Of the handler-based table frameworks, 'tdata' is more appropriate for tables that can be stored (or a copy cached) within the agent itself, while 'iterate' is more relevant to reporting data from outside the agent. The raw interface is only suitable in very specific circumstances, so it's probably sensible to start with one of the other frameworks first, and only look at this if none of the alternatives seem to work.

The decision between the handler-based configs and MfD is more a matter of the style of programming to use. Most of the frameworks define a single handler routine to process an incoming request, so all of the code is listed together, with the MIB programmer inserting table-specific processing into this single block of code. The MfD provides a series of individual object-specific routines, each concerned with one very specific task, and hides as much as possible from the programmer.

If you like to understand the broad thrust of what's happening, then one of the handler-based approaches would be the best choice. If you prefer to concentrate on the nitty-gritty of a given table, and are happy to trust that the rest of the processing will work correctly, then the MfD framework would be more appropriate.

For implementing a group of scalar objects, then the choice is simple - use 'mib2c.scalar.conf'.

Similarly, for generating traps or informs, use 'mib2c.notify.conf'.