Table iterator
Net-SNMP MIB Helper | |
Table Iterator | |
Documentation: | doxygen API |
---|---|
Code: | agent/helpers/table_iterator.c |
Other Helpers: | Agent Helpers |
Contents
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.
Note: the Table Iterator Helper is a child-helper of the table helper. You might want to read its documentation as well.
Pros and Cons
Pros
- It's very easy to implement a wrapper using it.
- You don't need to worry about sorting your data properly, the table_itator does this for you.
Cons
- The iterator helper will iterate through all the rows for each individual request which isn't very efficient.
Con Mitigation
- If you're data is sorted properly for SNMP already, set the NETSNMP_ITERATOR_FLAG_SORTED flag in the netsnmp_iterator_info's flags.
- Cache your data yourself using the cache_handler
- Inject a stash_cache helper, which is extremely efficient and fast at the expense of memory.
- Use a different table helper instead, such as the table_tdata or MIB for Dummies helpers.
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.