Thanks Dave for being so helpful. I have got a working agent that can
respond to queries on both Scalars and Tables. I chose iterator helper
mainly because my data is stored externally. Then I realized I still need
to copy the table data into a linked list locally into the memory so that
the interator can walk through the table by referencing the index via
getFirstContext and getNextContext. Because the FAQ says "iterator helper
assumes that the table data is held externally to the helper", It's a bit
different from what I expected and therefore I asked the question did I
choose the right helper. I think that FAQ actually means to choose
iterator helper if the external data is independent of the SNMP agent.

I got so many troubles probably because I tried to implement the agent
manually instead of using the mib2c helper to generate the code
automatically. I had a problem when using mib2c. The mib2c kept returning
/usr/bin/perl: symbol look up error: /usr/local/lib/libsnmp.so.10:
undefined symbol: RAND_bytes. until I finally found out I have to
explicitly specify the openssl library file path using
--with-openssl=/usr/lib. I've tried mib2c.table_data.conf, mib2c does make
things much easier.

Many Thanks

/Pan

> It's impossible to answer that question.
> The iterator helper is a perfectly reasonable choice for
> implementing a table (though perhaps not the most efficient).
>
> If it does what you need, then use it.
> If not, then try one of the others.
>
> See the FAQ entry
>     What's the difference between the various mib2c configuration files?
>         http://www.net-snmp.org/wiki/index.php/FAQ:Coding_07
>
> for a brief description of the various options.
>
> My personal preference is for 'mib2c.table_data.conf',
> but other developers have different preferences.
>
>
>> 3. The sample code has three components:
>> + an init function which get called when receiving requests.
>
> No - the init function is used to register the table when the agent first
> starts up.   This is how the agent knows where to send requests for
> this table.
>
>
>> + two functions getFirstContext and getNextConext that can be assigned
>> to
>> hooks
>
> These are use to select the appropriate row for a given request.
> When the agent receives a request for an OID in the table, it starts by
> calling the getFirstContext hook routine , followed by the getNextContext
> hook routine (repeatedly).   Your code should walk through the various
> rows of the table (in whatever order is most convenient), reporting on
> the various index values.
>
> The iterator helper can then use this information to select the
> appropriate
> row for this request.
>
>
>> + a handler function
>
> This is the bit that actually handles the request.
> It's given the row chosen by the getFirst/NextContext routines,
> and should extract (or update) the appropriate column value.
>
>
>
>> The question is how should I insert my code to tell which row is being
>> read or updated (GET or SET).
>
> That's handled by the iterator helper.
>
>> I think there should be an indexing mechanism or something,
>> but I couldn't find it in the vacm_context example.
>
> That's the role of the getFirstContext/getNextContext routines.
> In particular, the statement:
>
>     snmp_set_var_value(put_data, context_ptr->context_name,
>                        strlen(context_ptr->context_name));
>
> which returns the index value for each row (i.e. the context name)
>
> Dave
>



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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

Reply via email to