2
votes

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?

2
You write about "... read MIB once and save the OID translations ..." with what I take to be skepticism; are you concerned that you'll overflow memory? The MIBs--or at least the parts that matter to you--are likely to be reasonably small. It wouldn't surprise me that you can simply keep them in PHP variables representing the tree. I would start my experiments there. In any case, this would be far from the first MIB browser coded in PHP ...Cameron Laird
No, it is not skepticism - I don't see a way to get all possible OID translations from MIB file (just functions to translate known single ODIs/names). Am I missing something here? BTW: I need to browse the possible values, not the values on the device... I hope it makes sense. :)johndodo
johndodo, we might be confusing each other. In replying, I want to emphasize: PHP-coded MIB browsers are already available, and might interest you. Beyond that, I'm just recommending that you walk the whole MIB and keep all the data that might matter to you. Would you like code that does that?Cameron Laird
Cameron, either a working PHP-coded MIB browser (I couldn't find any) or an example on how to walk the whole MIB in PHP (couldn't find a way) would be great! I would prefer the latter though. ;)johndodo
I see where we might misunderstand each other - I want to know all the possible values from MIB file, without querying the device. AFAIK PHP SNMP functions don't allow that?johndodo

2 Answers

2
votes

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!

1
votes
smidump -f identifiers <MIB_filename>

If the MIB isn't up to par with it's syntax, use

smilint -ms <MIB_filename>

That should get you started