How to add row in a MIB table with snmpset?

时光怂恿深爱的人放手 提交于 2019-12-23 15:27:17

问题


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"

回答1:


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


来源:https://stackoverflow.com/questions/32756536/how-to-add-row-in-a-mib-table-with-snmpset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!