I like the code format of the iterate_access output but the -S cache=1
option does not generate the cache access code as in the iterate option.

The only real difference I see in the code is the access code is put into a
separate file, with some support routines also.  The iterate option is a bit
lower level

Is there a way to turn on the caching with mib2c.iterate_access.conf?

Any advise is appreciated.
Adam




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dave
Shield
Sent: Tuesday, March 13, 2007 8:07 AM
To: Zhang Chuan
Cc: [email protected]
Subject: Re: Decrease execute times of get_first_data_point() when getBulk

On 09/03/07, Zhang Chuan <[EMAIL PROTECTED]> wrote:
> Since I want to get the newest data from system when a GETBULK message 
> come in. I have an init_table() function in get_first_data_point(). 
> The
> init_table() function get the data from system by TCP and set them to 
> a given dataset. Then get_next_data_point() can get data from the 
> dataset and return to manager.

If you are loading the table into the agent every time, then the iterate
handler is probably not the best choice.  This is primarily designed for
tables where the number of rows (and their indexes) is not known to the
agent, and has to be retrieved from "outside".

Given that you are loading the table into the agent, I'd suggest that you
look at using one of the "internal-data" helpers - such as 'tdata'.   This
allows the agent to go directly to the relevant row for any given request,
without having to search through the whole table every time.

The bulk of the code will look similar to the handler you're already used to
- there'll just be a couple of minor differences in how to retrieve the
relevant row from the request structure.  But mib2c will generate a suitable
template for you.

This can also generate the basic framework for loading and releasing this
internal cache, using a standard helper.  That's basically Adam's
suggestion, but with most of the work done for you automatically.
(And manageable via SNMP!)

An alternative approach would be to use Robert's MfD framework, which can
also handle both iterative and internal data tables.  But the look of that
code is completely different to what you're used to, so it might be simpler
to stick with relatively familiar code.




> I have read some others questions similar with mine. The answer is 
> change to netsnmp_inject_handler instead of mib2c.iterate.conf.

No - that's not really correct.
"netsnmp_inject_handler" is a relatively low-level API, which is often used
as part of implementing a given table helper.  But you'd still need to
decide which
helper(s) to make use of.   It's not usually necessary to fiddle about with
this
directly - most of the time it's hidden away in the helper initialisation
routines.


>

> Is there anyone can show me a way not to change the helper but modify 
> my code to decrease the execute init_table() times?

Use the cache helper - either with the existing iterate helper, or switch
to the tdata helper.   Try running mib2c using

    mib2c -S cache=1   -c mib2c.iterate.conf ....
and
    mib2c -S cache=1   -c mib2c.table_data.conf ....

and compare the resulting frameworks.
The "init_table" stuff would need to be moved into the cache load routine,
but the main handler itself should be relatively unchanged.

Dave

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's
Techsay panel and you'll get the chance to share your opinions on IT &
business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

The information contained in this electronic mail transmission may be 
privileged and confidential, and therefore, protected from disclosure. If you 
have received this communication in error, please notify us immediately by 
replying to this message and deleting it from your computer without copying or 
disclosing it.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to