FAQ:Coding 02

From Net-SNMP Wiki
Revision as of 17:03, 23 November 2006 by Dts12 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How does the agent fetch the value of a MIB variable from the system?

That's typically the hardest bit of implementing a new MIB module, and is the one thing that 'mib2c' can't help with. It very much depends on the MIB variable concerned (and often the underlying operating system as well).

Relatively few MIB modules are completely self-contained, with all the information held internally within the agent, and all updates being done via SNMP requests. Such MIB modules can be implemented fairly easily.

More commonly, the agent needs to provide an SNMP-based interface to information held elsewhere, perhaps in the operating system kernel or some other application. Handling this is much more complex - since a lot depends on what mechanisms are provided for retrieving (and possibly updating) this information. The mib2c tool can generate code for processing SNMP requests, based on some internal cache of management information, but it cannot help with populating this cache with the underlying data. That is up to the MIB implementer.


See the existing MIB modules in the Net-SNMP source tree for various examples of assorted approaches to this task.

   FAQ:Coding
   
  1. How do I write C code to integrate with the agent?
  2. How does the agent fetch the value of a MIB variable from the system?
  3. Mib2c complains about a missing "mib reference" - what does this mean?
  4. Mib2c complains about not having a "valid OID" - what does this mean?
  5. Why doesn't mib2c like the MIB file I'm giving it?
  6. Mib2c ignores my MIB and generates a pair of 'mib-2' code files. Why?
  7. What's the difference between the various mib2c configuration files?
  8. Which mib2c configuration file should I use?
  9. How can I have mib2c generate code for both scalars and tables?
  10. Are there any examples, or documentation for generating MIB modules?
  11. Where should I put the files produced by 'mib2c'?
  12. Why doesn't my new MIB module report anything?
  13. Why does the iterator call my get_{first,next} routines so often?
  14. How can I get the agent to generate a trap (or inform)?
  15. How can I get an AgentX sub-agent to generate a trap (or inform)?
  16. How can I get the agent to send an SNMPv1 (or SNMPv2c) trap?
  17. How can I get the agent to include varbinds with an SNMPv1 trap?
  18. How can I get the agent to send an SNMPv1 enterprise-specific trap?
  19. How can I get the agent to send an SNMPv3 trap (or inform)?
  20. Why does calling 'send_v2trap' generate an SNMPv1 trap (or vice versa)?
  21. How can I register a MIB module in a different (SNMPv3) context?