[AGENT++] Index allocation for multi-index shared table fails

Isaac Nickaein nickaein.i at gmail.com
Wed May 23 08:19:10 CEST 2018


Hi Frank,

Thank you for the guidance on AgentX architecture. That's explains why the
subagent always got only the first sub-index.

1. It seems the region registration can be done with
SubAgentXMib::register_region. Is there any example/reference code on
region registration to demonstrate it?

2. To unregister a region, It seems that register_region should be called
with the same argument except with mode=FALSE. Is this correct?

3. The documentation mentions that the last argument, *reference*, is a
pointer to the AgentXSharedTable "which initiates the registration". What
should be done in the table instance (e.g. overriding a method, calling
register_entry, etc) to manage registration?


By the way, I have managed to get the multi-index working by the following
*HACK* in which uses a
single OID index type instead of two INT types for AgentXSharedTable:

const index_info my_index_info[] = {
       {sNMP_SYNTAX_OID, FALSE, 2, 2}
};

const Oidx my_index_oids[1] = {
       "1.3.6.1.4.1.38523.1.2.1537.1.1.1.1.1.1"
};

However, there seems to be a memory leak in master. I start and stop the
subagent multiple times. Each time the subagent will register the same
table and same indices and then calls *remove_row* on all rows and *clear*
for my AgentXSharedTable upon exit, but the memory footprint of master
agent increases without any decline.

4. Is there anything else that should be done to free up this memory in
master agent?

Nevertheless, the region registration seems a promising approach and
probably with less complications. I try to see how things work with it.


Cheers,
Isaac

On Thu, May 17, 2018 at 11:07 AM Frank Fock <fock at agentpp.com> wrote:

> Hi Isaac,

> The problem is the AgentX standard. It defines that only the first
sub-index is relevant for the index allocation.
> That is, of course, below common expectations. My recommendation is to do
only region registration and to leave index allocation unused. It provides
not much benefit for multi-variable indexed tables.

> Hope this helps anyway.

> Best regards,
> Frank


> > On 16. May 2018, at 15:44, Isaac Nickaein <nickaein.i at gmail.com> wrote:
> >
> > Hi,
> >
> > The shared table with multi-index is defined as below:
> >
> > char* oid_table_root = "1.3.6.1.4.1.38523.1.2.1537.1.1.1.1.1";
> >
> > index_info my_index_info[2] = {
> >     {sNMP_SYNTAX_INT, FALSE, 1, 1},
> >     {sNMP_SYNTAX_INT, FALSE, 1, 1}
> > };
> >
> > const Oidx my_index_oids[2] = {
> >     "1.3.6.1.4.1.38523.1.2.1537.1.1.1.1.1.1",
> >     "1.3.6.1.4.1.38523.1.2.1537.1.1.1.1.1.2",
> > };
> >
> > MyTableStatus::MyTableStatus(Agentpp::SubAgentXMib* mib_root)
> > : AgentXSharedTable(
> >     oid_table_root,
> >     my_index_info, 2,
> >     my_index_oids,
> >     mib_root,
> >     OctetStr()
> > )
> > {
> >     // Code to add columns
> > }
> >
> >
> > I have tried different ways of allocating a multi-index for this table,
but
> > all of them fail with error 259 (AGENTX_INDEX_ALREADY_ALLOCATED):
> >
> >
> > void MyTableStatus::my_init_table_rows()
> > {
> >     for(int dev_id = 0; dev_id < 10 ; dev_id++)
> >     {
> >         for(int tuner_id = 0; tuner_id < 4; tuner_id++)
> >         {
> >             // Index1 value: dev_id+1
> >             // Index2 value: tuner_id+1
> >
> >             // Method 1
> >             // std::string index_oid_str = std::to_string(dev_id + 1) +
"."
> > + std::to_string(tuner_id + 1);
> >             // Oid index_val_oid(index_oid_str.c_str());
> >
> >             // Method 2
> >             // Oid index_val_oid;
> >             // index_val_oid += Oid(std::to_string(dev_id + 1).c_str());
> >             // index_val_oid += Oid(std::to_string(tuner_id +
1).c_str());
> >
> >             // Method 3
> >             unsigned long* oid_values = new unsigned long[2];
> >             oid_values[0] = dev_id + 1;
> >             oid_values[1] = tuner_id + 1;
> >             Oid index_val_oid(oid_values, 2);
> >
> >             // Request new index
> >             Oidx index_val(index_val_oid);
> >             this->allocate_index(index_val);
> >         }
> >     }
> > }
> > _______________________________________________
> > AGENTPP mailing list
> > AGENTPP at agentpp.org
> > https://oosnmp.net/mailman/listinfo/agentpp


More information about the AGENTPP mailing list