On 25 August 2010 09:40, AC. <achuan...@gmail.com> wrote:
>> > I see that the command "snmptable" use the "getnext" to retrive the
>> > information,
>> > but is that correct cause I don't need the information of table B?
>>
>> Please consider the following question:
>>   - How does the snmptable command know when it has
>>     received the last row of table A?
>
> I also think so, but It is a waste of resource, especilly in my condition.

It's not a question of "waste of resources".
This is fundamental to how walking SNMP tables works.
You will *ALWAYS* run off the end of one table, and
on to the next.   That's the only way that the client command
knows that it has reached the end of the table.



> There are 3 main contact function in my code.
> 1. handler
> 2. get_first_data_point: It wll get all the data of the table
> 3. get_next_data_point
> When I typed "snmptable" to get table information, I find the handler was
> contacted servel times,

Yes - once for GETNEXT request.
  (Which is typically once for each row of the table)
*ALL* table handlers work this way - they are inevitably
called once for each incoming request.   You cannot
get away from that.


But you've suddenly changed the question.
You are no longer talking about switching from the table A
helper to table B.   You now seem to be concerned about
how often the table A code is being called.


> and the get_first_data_point function was contacted the same times.

Yes - that's how the iterator works.
For each individual incoming request (GET or GETNEXT),
the 'get_first' hook routine will be called once,
and the 'get_next' hook routine will be called multiple times
(typically as many times as there are rows in the table).

We state very clearly in the documentation that the iterator
helper is not the most efficient mechanism for implementing
a table.   It's designed for relatively small tables, where the
data is naturally held in a "random" order.


> So it will get ALL data of the table servel times. (the waste of resource)

Which is why we repeatedly recommend that people use the cache
helper, which will save re-loading the table data multiple times
in quick succession.



> I want to improve it

a)  Look at using the cache helper
   ("mib2c -S cache=1 -c mib2c.iterate.conf ...")

b)  Look at using one of the other table helpers
   (e.g. "mib2c -S cache=1 -c mib2c.table_data.conf ..."
     or the MfD framework)


But if you use one of the more inefficient helpers,
in a relatively inefficient way, then yes - you are going to
see performance implications.


Dave

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to