How to sync a MibTable with an STL::vector?

Frank Fock Frank.Fock____t-online.de
Tue Apr 15 02:14:02 CEST 2003


Hi Stefan,

Comments inline:

Stefan.Mueller-Wilken____resco.de wrote:
> 
> 
> 
> Hi there!
> 
> Ok, I admit it: I'm lost within the realms of table construction...
> 
> What I want to do is to have an STL::vector (first version, later to be
> changed to a MySQL table) be accessible via SNMP get- and set-requests.
> I've got no problem with initializing the table at startup. I use a
> MibTable derivate, add columns and iterate through the vector, adding rows
> and replacing their values at MibTable instantiation. So far, so good. What
> I just can't get a grasp on is how to handle changes, additions  etc. to
> the vector and how to keep the corresponding MibTable in sync later on.
> 
> Quite a few posts to the list have dealt with similar problems (esp.
> synchronizing MibTables with database tables) and have hinted at using the
> MibTable::update(...) method. The documentation explains that
> MibTable::update() is used by the Mib to find out about the number of rows
> the receiver contains. Sounds as if this should be the right place to
> rebuild the MibTable from the vector!
> 

Yes, it is.

> Unfortunately, my experiments show that MibTable::update(...) is called
> _on_every_ columnar _and_every_ row and not - as I would have expected -

That's not true. The "update" method is at least called once
per sub-request! It totally depends on the request!

> once per table. Additionally, the Request* changes on every call, rendering

That's also not true. The request pointer changes only if there
is a new request being processed.

> my effords to ignore subsequent calls to update useless. And it seems quite
> a waste to make n x m calls to change the n rows of my m column table. Do I
> really have to completely zap the MibTable and rebuild it from scratch on
> every call? What's the proper way to do the trick?

No. You are free to implement whatever caching stragety
you like. It could be time based (refresh table only every
2 seconds), or you could do some examination of the request
and do some "intelligent" refreshing.
> 
> Just to make things worse, I couldn't find any (complete) examples on how
> to sync Agent++ MibTables with databases or STL containers in posts to the
> lists or in the documentation. :-(
> 
This is probably because there is no general way to
solve the problem, it depends on your requirements,
environment, and target system.

> Could anyone who has done this before set me on the right track and help me
> with a complete example source? Thanks!
> 

I hope the above comments were helpful though.

Cheers,
Frank





More information about the AGENTPP mailing list