如何在net-snmp中查看DEBUGMSGTL的日志
我正在尝试编写一个使用net-snmp支持的agentX的snmp子代理。 首先,我使用了 net-snmp FAQ 中的示例代码:
http:// /www.net-snmp.org/wiki/index.php/TUT:Writing_a_Subagent
以及示例代码 (example-demon.c,nstAgentSubagentObject.c,nstAgentSubagentObject.h),我构建了一个可以使用agentX执行snmpget和snmpset的子代理。
我的问题是: 从nstAgentSubagentObject.c中的代码来看,有很多跟踪代码,如下所示:
DEBUGMSGTL(("nstAgentSubagentObject",
"Initializing the nstAgentSubagentObject module\n"));
但我在任何地方都看不到日志。
我尝试通过以下方式启动 snmpd (snmp 的恶魔) snmpd -f -DnstAgentSubagentObject -Lf /tmp/snmp.log
。
但我还是看不到日志。谁能告诉我如何查看 DEBUGMSGTL 的日志?
I am trying to write a snmp subagent that using agentX, which is supported by net-snmp.
At first, I used the example codes from net-snmp FAQ:
http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_Subagent
And from the example codes
(example-demon.c,nstAgentSubagentObject.c,nstAgentSubagentObject.h), I build a subagent which can use agentX to perform snmpget and snmpset.
My question is:
From the code in nstAgentSubagentObject.c, there are many trace codes such as follows:
DEBUGMSGTL(("nstAgentSubagentObject",
"Initializing the nstAgentSubagentObject module\n"));
But I can't see the log anywhere.
I tried to start snmpd (demon of snmp) bysnmpd -f -DnstAgentSubagentObject -Lf /tmp/snmp.log
.
But I still can't see the log. Could anyone tell me how to see the log of DEBUGMSGTL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可以设置标志:
或者如果您想查看所有日志:
i can just set flag :
or if you want to see all logs :
您希望在启动子代理时将该命令行选项传递给子代理,而不是使用
-D nstAgentSubagentObject
启动snmpd
。在教程中,它建议使用以下命令启动子代理:
要启用更多调试消息,请尝试使用以下命令启动它:
如果我没记错的话,应该将调试输出打印到控制台。如果您希望将其写入文件,可以将其与
-L
选项结合使用。Instead of starting
snmpd
with-D nstAgentSubagentObject
you want to pass that command-line option to your subagent when you start it.In the tutorial it suggests starting the subagent with the following command:
To enable the more debug messages, try starting it with the following command instead:
If I remember correctly, that should print out the debug output to the console. You can combine it with the
-L
option if you'd prefer it written to a file.仅供参考,您还可以将以下内容放入 snmp.conf 文件中,并在那里调整选项:
但是,另一个答案是正确的:您需要在代码将被命中的位置打开调试,该调试位于子代理中( snmp.conf 文件将被两者读取)。
FYI, you can also put the following into a snmp.conf file and twiddle the options there too:
But, the other answer is spot on: you need to turn on debugging where the code will be hit, which is in the subagent (the snmp.conf file will be read by both).