[AGENT++] Hmmm, another try with the table questions?

Frank Fock fock at agentpp.com
Thu Jun 17 09:03:24 CEST 2004


Hi,

Mr. AWD wrote:

>Hi there,
>
>I was under the impression that this will be relatively easy to do as much as dealing with the scalar objects, but I think that I am just struggling too much to have this done. The problem is to get the table with one and two indexes working correctly.
>
>  
>
The number of indexes for your table does not impose any additional 
complexity with AGENT++.

>I tried to follow the Agent++ 2.1 manual, but it is not clear enough to me what to do here. The solutions that I have for the particular problems seem a bit overdone and I can’t help but think that there must be an easier way.
>
>  
>
AGENT++ itself come with a couple of table implementations. For simple
ones, you can take a look at the snmp_target_mib.cpp file. For complex
ones, you can take a look at v3_mibs.cpp (the USM MIB implementation).

>Here is the thing. Code created with AgenPro 2.1 comes with the all table objects added in the constructor with add_col() function. Then there is also set_row() function that sets all of the elements for the particular raw at once. So, it looks like that once the GET request arrives and get_request() gets called, I would have to get all of the values for the whole row and set them with the set_row(). Even if I would need to return just one of the elements from the table I would have to set the whole row? Right? Example would be of great help here…
>
>  
>
You can set the whole row, but that's not needed. You have several options
(this may be confusing I have to admit):

1. Within the MibLeaf::get_request method, directly replace the value 
member of the MibLeaf.
2. Within the MibLeaf::get_request method, use MibLeaf::replace_value to 
set the value (better than 1)
3. Within the MibLeaf::get_request method, use one of the overridden 
set_value methods (not recommended)
4. Within the MibLeaf::get_request method, use the AgenPro generated set 
method to set the value (recommended)
5. Within the MibLeaf::get_request method, use the AgenPro set_state 
method to set the value (recommended as 4 and easy to use)
6. Within the MibTable::get_request method, use set_row to set the whole 
row.
This is not very efficient since you will have repeat that for each 
sub-request.
7. Within the MibTable::update(..) method, you can add/remove rows 
dynamically before a request is
processed. Overwriting the MibTable::update method is recommended for 
large tables that do not fit
efficiently into memory. Those tables are then implemented as virtual 
tables where only the needed
rows are actually present at a time.

I hope I have not forgot any approach here...

>On the other hand, I am also struggling with setting up the rows and the right number of them. I still didin’t figure out the best way to know when and how to create them. I mean, there is add_row() function that sets a row with the particular index (parameter of the function), but I believe that there has to be an easier way to figure out when to add a new one and when not and where to do that! Again, an example would worth a lot here!
>
>  
>
A good place to add/remove rows is the MibTable::update method. Since 
this method
could be called more than once per request by AGENT++, it is recommended 
to implement
a sort of timeout to not update the table too often.

>So, I did see an example of the ATM mib and there is use of the “Sim” objects (like SImMibLeaf) and I am not sure that I understand how all of that works. If that is the way to do it, I guess I would need to specify to the AgenPro to build the stubs with the “Sim” objects, but as of now I am still quite confused about all of that.
>
>  
>
The Sim objects are for simulation agents only. You should not use them 
in a real agent that
gets its MIB data from real subsystems (simulation agents get their MIB 
data via SNMP!)

>So, any place to look for some examples or a tutorial that could help would be really nice to see!
>
>  
>
There are additional (simple) examples about table usage in the AGENT++ 
examples directory.

Hope this helps.

Best regards,
Frank




More information about the AGENTPP mailing list