解析 SNMP MIB 文件(OID 转换)
我正在制作一个网络设备监视器。它的一部分是 PHP 前端,用户可以在其中输入他感兴趣的 SNMP 值(SNMP OID)。我想让用户的过程更简单,所以我想创建一个简单的 MIB 浏览器,允许用户从树中选择值。
问题是将 MIB 文件读取到数据库(或至少是类似 XML 的格式),我可以将它们呈现给用户。即时解析 MIB 文件对我来说似乎很浪费,因此排除了 PHP 的 snmp_read_mib() - 除非我可以读取 MIB 一次并将 OID 翻译保存到 DB?
另外,如果可能的话,我想避免编写自己的解析器。 :)
我找到了 libsmi 但我不知道如何在这种情况下使用它...我尝试使用 smidump 但只能创建一些简短的 XML,没有有用的内容。不过,我还没有尝试 xmldump,因为它在 Debian 上不可用(作为包),并且必须从源代码构建它。另外,我认为这是 2005 年的。有帮助吗?
所以问题是:如何从 MIB 文件中读取 OID 名称和/或其他数据(SNMP 陷阱信息)并将它们转换为某种现成的格式?
I am making a network device monitor. Part of it is a PHP front-end where user can enter the SNMP values he is interested in (SNMP OIDs). I want to make the process simpler for the user so I want to create a simple MIB browser, allowing user to select the value(s) from the tree.
The problem is reading MIB files to database (or at least XML-like format) from where I could present them to the user. Parsing MIB files on-the-fly seems wasteful to me so that rules out PHP's snmp_read_mib() - unless I can read MIB once and save the OID translations to DB?
Also, I would like to avoid writing my own parser if possible. :)
I have found libsmi but I'm not sure how to use it for this case... I tried using smidump but could only create some short XML with no useful content. I didn't try xmldump yet though, because it is not available on Debian (as package) and would have to build it from sources. Also, I think it is from 2005. Would it help?
So the question is: how can I read OID names and/or other data (SNMP Trap info) from MIB files and convert them to some ready-to-use format?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终使用了 Mibble - 我编写了一个小程序,它使用这个库来解析 MIB 并输出数据。非常简单,而且看起来效果很好。
尽管如此,还是感谢你们两位试图帮助我——我很感激!
I ended up using Mibble - I wrote a small program which uses this library to parse the MIBs and outputs the data. Very simple and seems to work nicely.
Still, thank you both for trying to help me - I appreciate it!
如果 MIB 不符合其语法,请使用
That 应该可以帮助您开始
If the MIB isn't up to par with it's syntax, use
That should get you started