On Fri, 10 Jul 2015 00:04:38 +0000 Mani wrote:
MP> Thanks for your reply. I was able to register a table oid and
MP> table_info structure using netsnmp_register_table(reginfo,
MP> table_info). When a request comes in, the handler gets invoked
MP> and by looking at the root oid I

Why are you looking at the root oid? Are you using the same handler
for multiple tables?

MP> am able to create a table_data_set if it does not exist with
MP> dynamic rows.

This is essentially what the cache handler does.

MP> I looked
MP> at netsnmp_table_data_helper_handler and mimicked that behavior
MP> for get and get-next except for the fact I call the dataset to
MP> fetch the first row or the requested row.

I think you are creating extra work for yourself. You shouldn't
have to mimic the behavior of the helper. The whole point of the
helper is to do the work for you.

MP> What I think I need to do is throw it into a cache with some
MP> configurable expiry time and then when a new request comes in
MP> check if it is in cache otherwise create the table.

Close. The cache helper doesn't check requests, it simply reloads
the data once the timer has expired.

MP> 1) since I created the table data set is there some way I can
MP> associate it with the requests and get the handler to do all
MP> the work. I don't want to add the code for get and get-next in
MP> my code. Also if there are several indexes I need to handle
MP> everyone of those cases. Can I inject another handler and do
MP> the processing after creating the table ?

This is exactly how handlers are supposed to work. Did you look at
initialize_table_nlmLogTable in
agent/mibgroup/notification-log-mib/notification_log.c? It creates
the structure, adds indexes, adds a default row (used when adding a
row to the table), then registers the table. It doesn't do any
handling of row lookups or get/get-next, because the data set
handler takes care of it.

MP> 2) Is there any example code to look at to create a cache
MP> handler ?

You can grep for netsnmp_cache_create in the agent/mibgroup
directory. There are lots of examples, though I couldn't find one
with a data set handler. It's pretty basic. You pass in a time, a
function to load the cache, a function to free the cache, and the
OID. There are flags that control the behavior. See the comments at
the top of agent/helpers/cache_handler.c for info on the different
flags.

Robert



------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to