On 08/09/06, Ambika Ramiya <[EMAIL PROTECTED]> wrote: > I have followed one of the following two mechanisms at a time > to populate and retrieve table contents. > > 1. Local to Net-SNMP: > > Here, arrays are declared for all the tables in .c file. > > 2. Using MySQL database: > > Here, I have stored the table contents in MySQL Database.
But you said initially that you were using the "table_data" helper? This works by holding all the data within the agent (handler) itself - not as tables within your code, and certainly not in an external source. The whole idea of the "table_data" helper is that the *helper* maintains the full contents of the table, and will fill in the responses to all requests. Your code would only be called as a "hook", to allow you to handle any special cases. Unless you explicitly populate this internal representation of the table with some content when you start, then as far as the helper is concerned, there's nothing in the table (and so no reason to call your handler). If you're wanting to hold the data yourself (either in a local array, or within a database), then the table_data framework isn't really appropriate. You'd be better off using one of the others. If the number of rows is relatively static, then you might want to look at the "container" helper. This holds a list of what rows are in the table (so it can decide which row is needed for any given request), but calls your handler to return the appropriate column value. So the "row structure" is totally opaque to the handler, and just needs to be sufficient for your handler code to retrieve the appropriate row data. This could be as simple as an index into the array, or a database key value. But the helper does need to have a full list of the valid rows (or row indexes), so it can decide which row is needed for any given request. It's possible to reload this list at regular intervals ("caching"), but it's really only suited for relatively stable tables. A second possibility would be the "iterator" helper, which allows you to specify the list of valid rows when a request arrives (using the "get_first,next}" routines to loop through them). Once again, the helper chooses which row is needed for this request, and calls the handler routine to supply the appropriate column. This is less efficient than the container helper (since it steps through the full list of rows for each request), but is more responsive to changes in the underlying data. Apart from the differences in selecting the relevant row, both of these work in essentially the same way for actually supplying the requested value - your handler is given the row to use, and just has to provide the corresponding column value. That holds for both GET and GETNEXT requests. The third possibility is to use the basic "table" helper. That's more efficient than the iterator helper, and more responsive than the container helper. But it does mean that you have to do more of the processing yourself. The table helper will parse the incoming OID, and extract the index value(s). But it's then up to your code to choose whether to retrieve this particular row (for GET and SET requests), or the next one (for GETNEXT/GETBULK). That's probably OK for simple single-index tables, but I'd advise against this approach for more complex tables (string-valued or multiple indexes). And there's no mib2c config file for this style, so you'd have to look at adapting code generated by one of the others (probably the container config). You may also have seen mention of Robert's MfD framework. This is a somewhat different approach to structuring the code for a MIB module, but the basic mode of operation is the same as the "iterator" and "container" styles described above. (The framework can generate code for either way of working). Hope this helps, and sorry there's no "One Right Answer". Dave ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ 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