将数据从我的程序获取到 snmpd
我想我可能错过了显而易见的事情,但我找不到一个好的答案。
我正在开发一个独立的程序,它将在硬件内的 Linux(Ubuntu?)嵌入式 PC 上运行。我希望它成为 SNMP 与之对话的“事物”。好吧,如果没有编译我自己的 SNMD“守护进程”代码并说服 Linux 让普通用户访问端口 161,我想我会选择 Net-SNMP 的 snmpd。我愿意接受更好的产品使用建议。 LGPL、BSD、MIT、许可证,谢谢。
我正在分别处理 MIB 和分配 OID 等。我知道我想要设置和获取什么变量等。
我已经阅读并重新阅读了有关制作 SNMP/snmpd 代理和/或子代理的内容。据我所知,它们都被编译成 snmp 或作为共享库链接到它。正确的?
那么,如何让该代理与在单独的一般用户会话中运行的单独程序进行对话?有没有可以直接使用的技术? D总线?彭()?命名管道?共享内存?临时文件? UDP端口?有更好的吗?或者我真的想将我的程序变成 .SO 并让 snmpd 启动它?我想那时我会告诉 snmpd 在哪里打电话给我来获取/设置变量。正确的?
谢谢!
I guess I have missed the obvious, maybe, but I am lost for a good answer.
I am developing a stand alone program that will be running on a Linux (Ubuntu?) embedded PC inside a piece of hardware. I want it to be the "thing" SNMP talks to. Well, short of compiling in my own SNMD "daemon" code and persuading Linux to let a general user have access to port 161, I think I'll opt for Net-SNMP's snmpd. I am open to suggestions for better products to use. LGPL, BSD, MIT, licenses, please.
I am working separately on the MIB and assigning OIDs, etc. I know what vars I want to set and get, etc.
I have read and reread the stuff on making an SNMP/snmpd Agent and/or subagent. Near as I can tell, they are both compiled into snmp or linked to it as a shared library. Right?
So, how do I get that agent to talk to my sepaprate program running in a separate general user session? Is there a direct technique to use? D-Bus? ppen()? Named pipes? Shared memory? Temp files? UDP port? Something better? Or do I really want to turn my program into a .SO and let snmpd launch it? I assume at that point I'd be abe to tell snmpd where to call in to me to get/set vars. Right?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“AgentX”协议是任意应用程序向正在运行的系统 SNMP 守护程序提供 SNMP 服务的一种方式。您的应用程序侦听 161 以外的某个端口(通常库会为您处理详细信息),并且系统 snmpd 会将您的 OID 请求转发到您的子代理。此方法不涉及将任何代码链接到系统 snmpd。
通常更简单的方法是配置系统 snmpd 以运行脚本来获取或设置数据。如果您愿意,该脚本可以使用其他类型的 IPC 与您的应用程序对话(例如与 HTTP 服务器的 JSON)。
The "AgentX" protocol is a way for arbitrary applications to supply SNMP services to a running system SNMP daemon. Your application listens on some port other than 161 (typically a library will take care of the details for you), and the system snmpd will forward requests for your OIDs to your subagent. This method doesn't involve linking any code into the system snmpd.
Often an easier way is to configure the system snmpd to run a script to get or set data. The script can, if you like, use some other kind of IPC to talk to your application (such as JSON to an HTTP server, for example).