Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add row in a MIB table with snmpset?

Tags:

snmp

net-snmp

mib

I changed recently my custom MIB file to include tables and not only scalars, it validates, I can create sub-agent etc. but if I try to read it, it says no entries:

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

Well, I didn't add any default/sample rows to that table in my agent code.

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

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

For example, sample table could look as simple as this one, where 'myString' is index:

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

}

EDIT: I didn't used RowStatus in my table. Am I required to use RowStatus to be able to add new rows?

EDIT2: I've compiled data_set.c agent from net-snmp samples, which populates a sample table with some data and can query its content with 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"
like image 521
lzdt Avatar asked Oct 30 '22 18:10

lzdt


1 Answers

Assuming, table (myTable) contains of a string (stringIndex) and 2 integers (test1 and test2), whereas 1st table column is also table index, you can add rows with following:

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 would need to call:

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

To verify your table content, you can use either snmpwalk or snmptable:

snmpwalk -v 1 -c public hostname:10161 yourMibName::myTable
like image 122
lzdt Avatar answered Jan 04 '23 15:01

lzdt