net-snmp 教程 snmpset 失败

发布于 2024-12-23 11:03:39 字数 1144 浏览 3 评论 0原文

我试图让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙女 2024-12-30 11:03:39

如果您在 64 位目标上进行编程可以提供帮助你

If you are programming on a 64bit target this can help you

青巷忧颜 2024-12-30 11:03:39

如果您想继续在 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(....)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文