Question re Table Updates
mcian2 opened this issue · 2 comments
**Just a question, not an issue
If I have to following provider:**
var myTableProvider = {
name: "smallIfTable",
type: snmp.MibProviderType.Table,
oid: "1.3.6.1.4.1_/SNIP/_3.3.2.1",
tableColumns: [
{
number: 1,
name: "SAC",
type: snmp.ObjectType.Integer
},
{
number: 2,
name: "SIC",
type: snmp.ObjectType.Integer
},
{
number: 3,
name: "System",
type: snmp.ObjectType.OctetString
},
{
number: 4,
name: "PointId",
type: snmp.ObjectType.OctetString
},
{
number: 5,
name: "ChAValue",
type: snmp.ObjectType.Integer
},
{
number: 6,
name: "chAValueLastUpdate",
type: snmp.ObjectType.Integer
},
{
number: 7,
name: "ChBValue",
type: snmp.ObjectType.Integer
},
{
number: 8,
name: "chBValueLastUpdate",
type: snmp.ObjectType.Integer
}
],
tableIndex: [{ columnName: "SAC" }, { columnName: "SIC" },
{ columnName: "System" }, { columnName: "PointId" }],
AND initilise the table using:
// SAC, SIC, System, PointId, ChAValue, ChALastUpdate, ChBValue, ChBLastUpdate
this.mib.addTableRow("smallIfTable", [ 210, 61, "TEST A", "ChannelStatus", 1, 1644515626, 123, 1644515000 ]);
this.mib.addTableRow("smallIfTable", [ 209, 96, "TEST A", "PSR", 3, 1644515637, 456, 1644515010 ];
this.mib.addTableRow("smallIfTable", [ 208, 26, "TEST B", "TSU", 2, 1644515648, 789, 1644515001 ]);
How can I update these rows after initialisation? Can I simply keep using addTableRow() using the same indeces? Or should I use setTableSingleCell (tableProviderName, columnNumber, rowIndex, value)?? If I have to use setTabeSingleCell() how would I determine the rowIndex prior to the update?
thanks!
After some tests I believe that in order to update using addTableRow(), I would have to know all the field values beforehand whereas using setTableSingleCell() only the field# and new value need to be known, which makes sense. I was confused by the rowIndex which I thought had to be a numeric, I now now that the json [ indexA, indexB, ... ] is all that is needed.
Hi @mcian2 - yes, addTableRow() will update an existing row for the same row index if it already exists.
Yes, row indexes can be a bit confusing. as SNMP tables can support non-integer keys, composite keys, foreign keys, and table augmentation. As such the row index is an array of index values, which the library ultimately converts into an array of integers.
This excerpt from the mib.getTableRowCells (tableProviderName, rowIndex)
section of the README may help shed some light on this:
Returns a single row of table data for the given row index. The row index is an array of index values built from the node
immediately under the column down to the node at the end of the row instance, which will be a leaf node in the MIB tree.
Ultimately, non-integer values need to be converted to a sequence of integers that form the instance part of the OID.
Here are the details of the conversions from index values to row instance OID sequences:
- ObjectType.Integer - single integer
- ObjectType.OctetString - a sequence of integer ASCII values
- ObjectType.OID - the exact sequence of integers in the OID
- ObjectType.IpAddress - a sequence of the four integers in the IP address