[AGENT++] MibTable and subagents

Razvan Cojocaru razvan.cojocaru at kaspersky.ro
Thu Apr 5 17:11:16 CEST 2007


Hello.

I'll try to reformulate my mishaps :-) : I'm using a MibTable with an
overridden update() method in an AgentX++ subagent, connected to
Net-SNMP's snmpd.

Unfotunately when I try to snmpwalk the table, nothing shows up. It's as
if the table is empty. The code is pretty straightforward, a la the
dynamic_table example in the agent++ (not agentX++) directory. When my
binary is a standalone SNMP server it all works fine, but as soon as I
switch to SubAgentXMib & friends, the tables all look like they're
empty. Traps works from the subagent, and MibLeaves work from the subagent.

I've looked at the initial registration code for tables from the
AgentX++ source code, and I've seen this (agentx_subagent.cpp:704):

if (entries.get()->type() ==
    AGENTPP_TABLE) {
        LOG_BEGIN(INFO_LOG | 2);
        LOG("SubAgentXMib: registering shared table rows (oid)");

        LOG(entries.get()->key()->get_printable());
        LOG_END;

        ((MibTable*)entries.get())->reinit();
        continue;
}

Now, this is MibTable::reinit():

/**
* Reinitialize the table. By default, this method does nothing.
* The method is called when a Mib instance needs to reinitialize
* its objects, for example, if a subagent needs to reconnect to
* its master agent.
*
* @since 3.5.22
*/
virtual void    reinit() { }

and this is AgentXSharedTable::reinit():

void AgentXSharedTable::reinit()
{
    OidListCursor<MibTableRow> cur;
    for (cur.init(&content); cur.get(); cur.next()) {
        allocate_index(cur.get()->get_index());
    }
}

My questions are: should I _always_ use AgentXSharedTable for subagents,
even if I _don't_ need to populate the same table from different agents?
Should I implement MibTable::reinit() in my table class? If so, what is
the best code to put there?

Obviously, I need dynamic tables that work with subagents, as well as
with standalone agents. All the table information (row population) can
be done from a single subagent. What is the best way to achieve that,
and how?

Thank you.


-- 
Razvan Cojocaru
KeyID: 1024D/04CA34DE




More information about the AGENTPP mailing list