dynamic MIB table row fetched from DB only when requested?

Alex Finogenov afinogenov____malibunet.com
Tue Mar 19 18:09:53 CET 2002


Kjersti,

Preloading of the agent with data for each request does work for GETNEXT if you overload MibTable::find_succ(). In that method you will need to call your business logic to return values for the subsequent conceptual row, whatever it might be from the SNMP MIB point of view.

For example, if your business objects are persisted in a relational database which is updated constantly, and you want to walk an SNMP table with an INDEX that corresponds to a DB column "I", you will have to:

- Retrieve a row index from an GETNEXT request.
- Query your database in a way that returns the values whose key follows the retrieved index.
- Assemble the "next" row and insert it to the table.

Alternatively, you can do the same in MibTable::update() for each of the varbinds, i.e. your table will be pre-populated before the Agent++'s code will process the response. This approach should include some trivial optimization.

The actual implementation a bit more complex, and takes into account that you may have to request initially the first conceptual row of your data, among other things.

All of the above implies that you clear the agent's table(s) after sending the response.

Alex



> -----Original Message-----
> From: Kjersti Grønnevik [mailto:kgr____morecom.no]
> Sent: Tuesday, March 19, 2002 4:58 AM
> To: agentpp-dl____agentpp.com
> Subject: dynamic MIB table row fetched from DB only when requested?
> 
> 
> Hi,
> 
> is it possible to implement a MIB table which has not 
> preloaded any rows.
> Our MIB table represents a DB table where rows are 
> sporadically inserted or
> deleted. My first thought was to not hold the rows in the 
> MibTable between
> requests, but dynamically update the MibTable for each request.
> 
> Here comes my problem: If I do not hold the rows in the 
> MibTable, apparently
> GETNEXT requests will not function - because there are no "next" row
> instanciated in the MibTable. Hence, I get the error message 
> - "No such
> name" from my mib browser tool (MG-SOFT).
> 
> Here's some of my code:
> 
> void lvAptIndex::get_request(Request* req, int ind)
> {
>  //--AgentGen BEGIN=lvAptIndex::get_request
> 
>  if(lvAptEntry::instance)
>  {
>   lvAptEntry::instance->update(req, ind);
>   set_state(lvAptEntry::instance->size());
>  }
> 
>  //--AgentGen END
>  MibLeaf::get_request(req, ind);
> }
> 
> 
> void lvAptEntry::update(Request* req, int subReqIndex)
> {
>   start_synch();
>   currentSubReqIndex = subReqIndex;
>   update( req );
>   lastRequest = req;
>   end_synch();
> }
> 
> void aptEntry::update(Request* req)
> {
>  if( req != lastRequest )
>  {
>   //rows()->clearAll();  // this did'n work .....  only in 
> debug mode  ....?
>    }
> 
>   Oidx oid = req->get_oid( currentSubReqIndex );
>   Oidx oid_aptId = oid.cut_left( 16 );//fetch the index from the oid
> 
>   MibTableRow* existingRow = find_index( oid_aptId );
> 
>  //add the row if the same row has not been added in this request.
>  if( existingRow == 0 )
>  {
>   //fetch row from db
>   long aptId = oid.last();
>   LVDatabase *db = LVDatabase::getInstance();
>   APTEntry aptEntry = db->getAPTEntry( aptId );
> 
>    // add the row with the row data from db
>    MibTableRow* newRow = add_row( oid_aptId );
> 
>   set_row(
>   newRow,
>   (long)aptEntry.getId(),
>   (char*)aptEntry.getFriendlyName().c_str(),
>   (char*)aptEntry.formatDateString().c_str(),
>     ......
>  }
> }
> 
> Hope this is understandable and thanks so much for great help so far!
> 
> Best regards,
> Kjersti
> 
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.agentpp.org/pipermail/agentpp/attachments/20020319/a8d5c4fb/attachment.htm 


More information about the AGENTPP mailing list