net-snmp 教程 snmpset 失败
我试图让 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
请帮助我明白我哪里做错了。所有文件都来自教程,我没有 改变任何事情。
提前致谢!
I am trying to make net-snmp to support my own MIB, but I failed. I was following the instructions here:
http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_MIB_Module.
Then I think maybe I could just use the example MIB file and .c and .h file to test if the example works. Again, by following the tutorials in the above link, I get this to work:
snmpget -v2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0
and I got this:
NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = INTEGER: 1
(which looks good).
But then I try to test snmpset like this:
snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 i 5
or
snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = 5
or
snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 INTEGER 5
and I got the following error:
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
Please help me understand where did I do wrong. All the files are from the tutorial and I did not
change anything.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在 64 位目标上进行编程此可以提供帮助你
If you are programming on a 64bit target this can help you
如果您想继续在 64 位计算机上运行,可以将变量从 int 更改为 long:
static int nstAgentModuleObject = 1;
==>静态长......
netsnmp_register_int_instance(....)
==>netsnmp_register_long_instance(....)
If you want to keep running on a 64bit machine you can change the variable from int to long:
static int nstAgentModuleObject = 1;
==>static long .....
netsnmp_register_int_instance(....)
==>netsnmp_register_long_instance(....)