[AGENT++] Index allocation for multi-index shared table fails
Isaac Nickaein
nickaein.i at gmail.com
Wed May 16 15:44:46 CEST 2018
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);
}
}
}
More information about the AGENTPP
mailing list