2

我试图让 net-snmp 支持我自己的 MIB,但我失败了。我按照这里的说明进行操作:http: //www.net-snmp.org/wiki/index.php/TUT :Writing_a_MIB_Module 。

然后我想也许我可以使用示例 MIB 文件和 .c 和 .h 文件来测试示例是否有效。同样,通过按照上面链接中的教程,我得到了这个工作:

snmpget -v2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0

我得到了这个:

NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = INTEGER: 1(看起来不错)。

但后来我尝试像这样测试 snmpset:

snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 i 5

或者

snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = 5

或者

snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 INTEGER 5

我收到以下错误:

Error in packet.
Reason: wrongLength (The set value has an illegal length from what the agent expects)
Failed object: NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0

请帮助我了解我在哪里做错了。所有文件都来自教程,我没有更改任何内容。

提前致谢!

4

2 回答 2

2

如果您在 64 位目标上编程,可以帮助您

于 2012-01-09T16:35:59.947 回答
0

如果您想继续在 64 位机器上运行,您可以将变量从 int 更改为 long:

static int nstAgentModuleObject = 1; ==> static long ..... netsnmp_register_int_instance(....)==>netsnmp_register_long_instance(....)

于 2012-06-06T11:18:05.353 回答