[AGENT++] How to code an Expansion Relationship between 2 tables
Schmutz, Felix
Felix.Schmutz at riedel.net
Tue Oct 14 15:25:51 CEST 2008
Hello All!
I am trying to create two tables with Agent++, one of them expanding the other one, so I want to have an expansion relationship.
Tough I am able to create the tables, I do not think that I got Agent++ to understand the relationship I want to have.
So the question is: how can I code an expansion table in Agent++ properly representing below MIB
Maybe one of you can help me out.
Explanation:
Table A (switchTable ) contains a list of all devices and their parameters of my system.
Table B (slotTable) contains a list of input cards that can be plugged into the devices. Table B shall effectively contain all cards of the whole system.
So Table B shall extend the indexing mechanism of the first table.
To maybe make it more clear, my MIB looks like this. (I think these semantics are correct, though it is my first "serious" MIB)
(...)
switchTable OBJECT-TYPE
SYNTAX SEQUENCE OF SwitchEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A table containing t a list of all devices and their parameters of my system"
::= { companiesOID 10 }
switchEntry OBJECT-TYPE
SYNTAX SwitchEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"An entry (conceptual row) in the switchTable."
INDEX { switchTableIndex }
::= { switchTable 1 }
SwitchEntry ::= SEQUENCE
{
switchTableIndex Counter64,
switchName DisplayString,
switchFwVersion DisplayString,
switchFanSpeed Integer32
}
switchTableIndex OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A unique identifier. Each device has one unique 64bit ID that shall be used as an index"
::= { switchEntry 1 }
(...)
slotTable OBJECT-TYPE
SYNTAX SEQUENCE OF SlotEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"extension table containing all cards and their parameters found in the system. The sort-of primary keys are the switchTableIndex(unique Identifier of a device) as well as the slotTableIndex (slot number (unique) in a given device). switchTableIndex shall be the foreign key from switchTable"
::= { companiesOID 20 }
slotEntry OBJECT-TYPE
SYNTAX SlotEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"An entry (conceptual row) in the slotTable."
INDEX { switchTableIndex , slotTableIndex }
::= { slotTable 1 }
SlotEntry ::= SEQUENCE
{
slotTableIndex Integer32,
slotName DisplayString,
slotTemperature Integer32,
slotCardEnabled INTEGER,
slotType DisplayString
}
slotTableIndex OBJECT-TYPE
SYNTAX INTEGER(0..100)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A unique identifier used to identify the slots, generally lower than 30"
::= { slotEntry 2 }
(....)
Please note that in the final version the DESCRIPTION will be better.
So in Agent++ I now did the following. I created two tables and used the index_info structure, because I think it has something to do with it.
But how can I tell Agent++ how to fill it?
My code looks like this
...
const struct index_info indDynamicTable[1] ={ { theType, FALSE, 1, 1 } };
const struct index_info indOfSlotTable[2] =
{ { sNMP_SYNTAX_CNTR64, FALSE, 1, 1 }, { sNMP_SYNTAX_INT32, FALSE, 1, 1 } };
MibTable switchTable(Oidx(Oids::conceptionalRowOfFrameTable), indDynamicTable , 1,);// conceptionalRowOfFrameTable = a string containing companiesOID::10.1
switchTable.add_col(new MibLeaf("1", READONLY, new Counter64(DeviceDaemon::SwitchSerial->Get()))); // this is the switchTableIndex
switchTable.add_col(new SnmpDisplayString("2", READONLY, new OctetStr( "someName" ) ));
...
MibTable slotTable(Oidx(Oids::conceptionalRowOfSlotTable), indOfSlotTable, 2,); //// conceptionalRowOfFrameTable = string containing absolute OID: companiesOID::20.1
slotTable.add_col(new MibLeaf("1", READONLY, new Counter64(DeviceDaemon::SwitchSerial->Get())));
slotTable.add_col(new MibLeaf("1", READONLY, new SnmpInt32 (DeviceDaemon::SlotNumber->Get())));
slotTable .add_col(new SnmpDisplayString(Oids::STnameSlotName, READONLY, new OctetStr("someName")));
if I now fill the tables by calling
Oidx next = table->get_next_avail_index();
MibTableRow* row = table->add_row(next);
The index column of switchTable is not pre-filled ==> fine.
I CAN fill it by calling lets say:
switchTableRow->get_nth(0)->replace_value(new Counter64 (switchID)); //I think I fill the index row
//fill additional values here
as well as
slotTableRow->get_nth(0)->replace_value(new Counter64 (switchID));
slotTableRow->get_nth(1)->replace_value(new SnmpInt32 (slotNumber));
//fill additional values here
That's fine, the way it is implemented, it is working, and by looking at the MIB one will be able to grasp the intended relationship, but I don't think that this is the supposed way how to do it?
Can one please point me in a direction how one should solve this? I don't find anything about table expansion relationships in Agent++ in any example/document. I'd really appreciate any suggestion and hints!
best regards,
Felix
More information about the AGENTPP
mailing list