Hi Dave/Dheeraj,

     Thanks a lot for your pointers and help.

    I have used the mib2c.table_data.conf with cache configuration
to generate a code. After fixing the bugs in the generated code, 

It works fine now.
    I just want to list the problems that I have fixed in
this generated code.

1) In initialize_table_* functions,
     replaced 'netsnmp_inject_handler_before' function call by
'netsnmp_inject_handler'.

2) In initialize_table_* functions,
     replaced 'netsnmp_cache_handler_GET' function call by
'netsnmp_cache_handler_get'.

3) In*_free functions,
     Replaced 'netsnmp_tdata_get_first_row' function call by
'netsnmp_tdata_row_first'.

4) In *_createEntry functions, 
    Removed the following code and added this in the
*_createEntry caller functions:

    netsnmp_tdata_row_add_index(row, ASN_UNSIGNED,
                                &(entry->clmgmtLicenseActionIndex),
                                sizeof(entry->clmgmtLicenseActionIndex));
    netsnmp_tdata_add_row(table_data, row);


5)  In *_handler function, 
    Added the following code in the MODE_SET_RESERVE2 case:

                            if (*request->requestvb->val.integer == 
RS_CREATEANDWAIT) {
                                netsnmp_tdata_add_row(table_data, row);
                            } else if (*request->requestvb->val.integer == 
RS_CREATEANDGO) {
                                 netsnmp_insert_tdata_row(request, row);
                            }
6)  In *_handler function, 
Added the following code in the MODE_SET_ACTION case:
  
            if (table_entry == NULL) {
                continue;
            }


Thanks,
-karthi


________________________________
From: Dave Shield <d.t.shi...@liverpool.ac.uk>
To: N. Karthikeyan <karthik_96...@yahoo.com>
Cc: "net-snmp-users@lists.sourceforge.net" 
<net-snmp-users@lists.sourceforge.net>
Sent: Thursday, September 15, 2011 12:54 AM
Subject: Re: Document for modifying the mib2c generated code

On 15 September 2011 00:24, N. Karthikeyan <karthik_96...@yahoo.com> wrote:
>      Could you please let me know whether there is any document
> available on how to change the mib2c generated code?

Not really.
I started writing a book on this, but it never really came to fruition.

The main problem is that "changing mib2c generated code" is too vague.
There are several different table frameworks, and they all work in
different ways.   What you need to change will be different for each one.

I *think* that Dheeraj's explanation refers to the iterate_access template
(or possibly MfD),  which are both rather different to ther iterator or
table_data approaches.


>                                                   I am trying
> to implement a table with mib2c.iterate.conf with cache enabled.

First thing - if you are caching the data within the agent, then there's
probably no point in using the iterator helper.
    This was originally designed for a situation where the (external)
data can come in any order, so does some (relatively inefficient)
processing to handle the sorting requirements.

If you've got a local cache of the data, then the MIB implementation
can know exactly which rows are present in the table, and go straight
to the appropriate row.
   I would strongly suggest that you look at using the table_data template
(+ cache) instead.    These two are reasonably similar, but the table_data
helper (strictly table_tdata) omits the  first/next  hook processing of the
iterator helper.


The main things you will need to change are in the  xxx_load routine
to populate the contents of the cache.    You may need to tweak bits
of the main handler routine (particularly for SET handling and creating
new rows),   but at first glance, that code seems more or less OK.

The template load routine is very simple (and incomplete (and slightly wrong!))

It assumes the basic data is read from a file - one line per row
of the table   (read using while fgets).
    If that's not true, you need to change this driving loop.

The first step is to identify the index value(s) of this row, and assign them
to the index variables defined at the head of the table.   This is simply
left as a comment in the generated template - you need to replace this
with the necessary code.

The next step (creating the entry in the local cache) is slightly wrong.
It should actually read

    row = xxx_createEntry(....);
    this = row->entry;

where 'this' is defined as a local variable of type  struct xxx_entry
(this definition is also missing from the template code)

The final element is to populate this data structure with the rest
of the values for that row.   Again, this is left as a comment in
the generated template - you need to provide the relevant code.



Hope this helps

Dave
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
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