On Fri, 2005-01-07 at 13:30, Sridhar S wrote:
> I have implemented ifTable using Net-SNMP agent toolkit. It is working
> fine. I have implemented by using table iterate stryle.
> This is what I observed is.
>
> 1. Agent receives a request from the manager
> 2. Iterates through all the rows available at the agent
> 3. Locates the row that matches the incoming index
> 4. Return value of the object under query
Yes - that's the model used by the table_iterator.
> I see a disadvantage here (please correct me if I am wrong). Assume we
> have configured 100 interfaces and manager queries for ifOutErrors for
> 100th interface. Then agent has to iterate through all 100 interfaces to
> locate the correct one. right ?
Correct.
One of the design features of the table_iterator helper, is that
it works with tables that are "unordered" (or ordered differently
to the MIB table indexing). This does mean that it's not the
most efficient table helper in the Net-SNMP arsenal!
> Can we optimize it ?
Sure.
Two immediate possibilities.
a) If the table entries *are* stored in the correct order,
then you can indicate this when you initialise the table:
netsnmp_iterator_info *iinfo;
iinfo->flags = NETSNMP_ITERATOR_FLAG_SORTED
The iterator will still walk through various rows of the table,
but it will be able to stop earlier in many cases, speeding things
up significantly (particularly for "early" rows)
b) You can use the 'stash_cache' helper to cache the results
of walking the table in a more quickly accessible form.
Add the line
netsnmp_inject_handler( reg, netsnmp_get_stash_cache_handler());
immediately after the 'netsnmp_register_table_iterator' call,
or add the line
injectHandler stash_cache NAME table_iterator
in the file snmpd.conf (where NAME is the name of your table
from the registration structure).
> so that agent gets the index/indicies under query
> and the type of request (GET/GET-NEXT/SET). The agent, instead of
> iterating through all the available rows, makes a direct query to the
> backend.
That sounds as if you might be better off using one of the other
helpers - perhaps 'netsnmp_register_table()' to handle most
of the processing yourself, or Robert's MfD structure.
(The table_container, table_data or array_user helpers feel less
relevant for "external" data like this, though you could probably
use the array_user helper. I'll let Robert comment on that.)
Dave
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users