2

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?

johndodo
  • 17,247
  • 15
  • 96
  • 113
  • 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 Sep 28 '11 at 13:02
  • 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 Sep 28 '11 at 13:09
  • 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 Sep 28 '11 at 17:18
  • 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 Sep 29 '11 at 08:20
  • 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 Sep 29 '11 at 12:03
  • johndodo, I'm traveling today. I'll meet you back here tomorrow. – Cameron Laird Sep 29 '11 at 14:36

2 Answers2

2

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!

johndodo
  • 17,247
  • 15
  • 96
  • 113
  • 1
    johndodo, thanks to *you* for reporting back your experience. You were quite right that my reading was careless, and did not recognize that you're working from the *file* rather than the LDAP instance. I'm glad to hear that your Mibble approach was successful. – Cameron Laird Oct 03 '11 at 23:44
1
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

EhevuTov
  • 20,205
  • 16
  • 66
  • 71
  • Thanks, but that just prints "aborting due to severe parsing errors" (testing on ExtremeNetwork's MIB: http://extremenetworks.com/libraries/services/v762b3.mib), switch "-k" doesn't help... smilint returns errors too, so I guess MIB is not correct. However, I still have to parse it. – johndodo Oct 03 '11 at 06:57