[AGENT++] MibTable-derived objects and AgentX++

Razvan Cojocaru razvan.cojocaru at kaspersky.ro
Wed Apr 4 18:47:22 CEST 2007


Hello.

I've registered some MibLeaves and some dynamic tables in my subagent,
and connected the subagent to Net-SNMP's snmpd.

However, when I snmpwalk my tree, only the MibLeaf objects show up.
There are no SNMP errors reported, and the update() method of my dynamic
tables does seem to be called (gdb stops in it with a breakpoint), but
the data that's supposed to be in the tables simply does not show up at
all. Nothing about the table OIDs either. It's like I never add()ed the
tables to the Mib in the first place (yes, I know you'll suggest that I
check that I add()ed the tables - and yes I did :-)). The same code
seems to work if the code is put in a master (standalone) agent binary.

The tables code looks something like this:

MyTable::MyTable()
    : MibTable("1.2.3.4.5.6"), currentRequest_(0)
{
    add_col(new MibLeaf("1", READWRITE, new SnmpInt32(0), true));
    add_col(new MibLeaf("2", READWRITE, new OctetStr(""), true));
    add_col(new MibLeaf("3", READWRITE, new OctetStr(""), true));
}

void MyTable::update(Request* req)
{
    if (currentRequest_ == req->get_request_id())
        return;

    currentRequest_ = req->get_request_id();
    start_synch(); // begin transaction

    MibTableRow* row = add_row("1");

    if(!row) {
        req->set_error_index(1);
        req->set_error_status(SNMP_ERROR_GENERAL_VB_ERR);
    }

    row->get_nth(0)->replace_value(new SnmpInt32(0)));
    row->get_nth(1)->replace_value(new OctetStr("")));
    row->get_nth(2)->replace_value(new OctetStr("")));

    row = add_row("2");

    if(!row) {
        req->set_error_index(1);
        req->set_error_status(SNMP_ERROR_GENERAL_VB_ERR);
    }

    row->get_nth(0)->replace_value(new SnmpInt32(0)));
    row->get_nth(1)->replace_value(new OctetStr("")));
    row->get_nth(2)->replace_value(new OctetStr("")));

    end_sync();
}

Am I missing something? Do I need to do something special for dynamic
tables to be supported in a subagent? Do I need to add() something
special to the SubAgentXMib object to allow for dynamic tables handling?

Thanks.


-- 
Razvan Cojocaru
KeyID: 1024D/04CA34DE




More information about the AGENTPP mailing list