How can I add a row to a MIB table using snmpset?

I recently changed my custom MIB file to include tables, not just scalars, it checks, I can create a sub-agent, etc., but if I try to read it, it won't write:

snmptable -v1 -c public hostname:10161 myMibName::myTable
myMibName::myTable: No entries

      

Well, I didn't add default / selections rows to this table in my agent code.

If I try to set some table values ​​using snmpset, similar to how I did it on scalars, it always fails, so the table requires its own syntax.

How can I add a row to a table using snmpset or similar?

For example, a sample table might look as simple as this, where "myString" is the index:

MyTableEntrySequence::= SEQUENCE {
myString
OCTET STRING,
test1
Integer32,
test2
Integer32

      

}

EDIT: I haven't used RowStatus on my table. Should I use RowStatus to add new rows?

EDIT2: I compiled the data_set.c agent from net-snmp samples, which populates a sample table with some data and can query its contents using snmptable:

snmpwalk -v 1 -c public hostname:10161 netSnmpIETFWGTable
NET-SNMP-EXAMPLES-MIB::nsIETFWGChair1."snmpv3" = STRING: "Russ Mundy"
NET-SNMP-EXAMPLES-MIB::nsIETFWGChair2."snmpv3" = STRING: "David Harrington"

      

+3


source to share


1 answer


Assuming that the table ( myTable

) contains the string ( stringIndex

) and 2 integers ( test1

and test2

) while the 1st column of the table is also an index of the table, you can add the following string values:

snmpset -v 1 -c public hostname:10161 yourMibName::test1.\"testString\" = 365

This adds a new table row where

stringIndex = "testString"
test1 = 365
test2 = 0

      



To set test2 to 42, you need to call:

snmpset -v 1 -c public hostname:10161 yourMibName::test2.\"testString\" = 42

To check the contents of your table, you can use snmpwalk or snmptable:

snmpwalk -v 1 -c public hostname:10161 yourMibName::myTable

      

+1


source







All Articles