Template:FAQ:Coding 02
This depends on the MIB variable (and the operating system).
Much of the 'mib-2'
information is extracted from kernel memory -
often by seeking to the appropriate location in the kernel itself and
reading the data structures directly.
Some systems provide cleaner interfaces to such kernel information
(it would be hard to think of a less clean interface!), via ioctl()
calls or similar system routines. Such mechanisms are usually used
in preference.
Some other MIBs may be implemented completely within the agent itself, where the necessary information is already being held internally. This particularly holds for MIBs relating to the operation of SNMP directly. Other MIBs may involve communicating with another running process, or using a variety of other sources.
There's no simple answer to this question, and obtaining the necessary information is often the hardest part of implementing a MIB. Writing the code is straightforward by comparison!