Table iterator

From Net-SNMP Wiki
Revision as of 17:01, 14 July 2011 by Wes (Talk | contribs) (Pros and Cons)

Jump to: navigation, search
Net-SNMP MIB Helper
Table Iterator
Documentation: doxygen API
Tutorial: Tutorial
Code: agent/helpers/table_iterator.c
Other Helpers: Agent Helpers

Table Iterator Helper

Overview

This handler calls user specified functions to iterate over a (generally unsorted) set of data, looking for the data to satisfy an incoming request.

Pros and Cons

The iterator helper will iterate through all the rows for each individual request which isn't very efficient.

If you're looking for better efficiency, you might want to consider using table_tdata or MIB for Dummies module style instead. Or adding a cache_handler cache to load the data first.

Tips and Tricks

Transient Data

If you are concerned that the data you are iterating over will change or vanish between the time the iterator functions are called and the time the handler is called to process a request, but you don't want to cache all your data, then there is an itermediate option.

If you provide a make_data_context function when you register the table, that function will be called with the loop_context for a row each time the agent determines that the current row is the best match. When the agent is done with the row, the free_data_context function will be called to release the data.