Re: SNMP Table Handling
Krishna Chaitanya <[email protected]>
| Newsgroups | gmane.network.net-snmp.devel |
|---|---|
| Message-ID | <CABPxzYL4ABzWNULnqCJ=qS5buEnA_4C5TDpbsLmjLFhz8kBkHQ@mail.gmail.com> |
On Thu, May 30, 2019 at 2:51 PM Krishna Chaitanya <[email protected]> wrote: > > Hi, > > I am just starting on SNMP and have a query on how to implement tables. > > I did go through forum messages and examples found below to be > helpful, but still, have doubts. > > https://sourceforge.net/p/net-snmp/mailman/message/33480025/ (This was helpful) > examples/mibgroup/netSnmpHostsTable.c > > I have a single API which will get 3 different types of stats (A, B, C) and each > stats can have multiple instances, so I have made 3 different tables (A, B, C). > > a) providing complete row > I want to provide the latest stats every time a request is made > (snmpwalk/snmptable). For that > I have registered a handler for each table and inside the handler, > fetching the stats. > But the problem is that the handler is called for every column? So, > for efficiency sake > I need to run a separate thread to fetch and fill only the column > asked in the handler? Is there a better approach? Like can I submit > the entire row at once? > > b) replace row asserts > FYI, I am using data_set tables it already has a handler but as I want > to update the table > with new values, I am doing a replace row (it causes duplicate warnings). > > Any help is appreciated. Thanks. > After spending some more time, able to get below optimizations: FYI, I am using table_data_set tables. In my custom table handler, I am doing below pseudo code: Is this the preferred approach? for (requests) //Try to update full row at once. if table->colnum != LAST_COL continue; //fetch existing row for (rows) row->index == table_info->index old_row = row break; row = fetch_and_prepare_data() replace (old_row, row)