Re: Doing a Table in net-snmp

Dave Shield <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
2009/8/21 Jared Smith (jarsmith) <[email protected]>:
> I’m trying to setup a table that will have two columns:

> I have seen other examples where in the handler you do something like the
> following:
>
> netsnmp_table_request_info *tableInfoPtr;
> tableInfoPtr = netsnmp_extract_table_info(request);
>
> switch ( tableInfoPtr->colnum){
> case 1:
>    snmp_set_var_typed_value(…..)


> Where each of the case statements would set a single column in a given row.
> But this seems best suited where a table only has a single row.

No.  All table-based handlers work with multiple rows.
Otherwise there would be no point in having a table in the first place!

Many (most?) table handlers will include a call to retrieve the row data
structure for a particular row - being the row that is relevant to that
particular request.   The MIB-specific handler only has to worry about
one row, because the various table-helpers have already identified which
row is needed.


>  ... What I
> really want to do is just re-populate the entire table each time any of the
> contents are requested to ensure the entire table is up to date.

Are you sure?  For every single request?
Remember that walking the table will be seen by the agent
as a series of individual GETNEXT requests.   Do you really
want to re-load the whole table for every single individual cell?
That's a very inefficient way of working!

A more natural approach would be to use an internal cached
copy of the table, and reload this whenever it's deemed "too old".
That could be as low as 1 or 2 seconds, to keep the contents
reasonably accurate, but should be long enough to accomodate
a typical walk of the whole table.




> Do I need to keep a reference to the netsnmp_table_data_set and then just
> update the entire table each time the handler is called?  Is there any
> tutorial or sample code that shows how to handle a table with multiple rows
> where the number of rows can change over time?

Almost any table will have a dymanically varying number of rows
I'd suggest that you start by running

   mib2c  -S cache=1 -c mib2c.table_data.conf   {myTable}

to generate a suitable starting template for your code.

Dave

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.