Unfortunatly, I've deep sixed the server I was building which used this module. I played with is a bit, so I will share what I can remember.

First you need to collect all the MIB files you are going to attempt to resolve OIDs out of. If I remember some stock mibs come with the module, which map certain trees of the OID structure, ala 3.1.2.1.6 ( I think *groan* ) which is the system sub tree.

Second you need to take those raw mibs and compile them and store them somewhere else.. I believe during the initialization of the mib object you need to define compile => '1', or something along those lines.. I know thats in the docs. Also you have to define a (i think the term is) respository. This will be where the compiled mibs are stored. I compiled all the MIBs I would need, then simply used the respository during run time, as opposed to compiling every run.

So while the code is very wrong, I will attempt a basic quasi walkthrough.

This code is wrong
First run #!/usr/bin/perl use SNMP::MIB::Compiler; $raw = '/var/tmp/mibs_files'; $proc = '/var/tmp/mib_compiler'; $mib = SNMP::MIB::Compiler->new( someargs => '', ); $mib{ 'repository' => "$proc", 'use_v1' => '0', 'use_v2' => '1', }; open(DIR,"$raw") || die "cant access dir $raw\nReason: $!\n"; for ( grep(!/^\./, readdir(DIR)) ) { $mib->compile("$_"); } closedir(DIR); ## Second run use SNMP::MIB::Compiler; $data = '/var/tmp/mib_compiler'; $mib = SNMP::MIB::Compiler->new( 'args' => 'blah', ); $mib{ repository = "$data", }; for ( @oids_to_resolve ) { # I think this converts numeric to text $name = $mib->convert($_); # whereas this will convert a string to numeric oid.. $oid = $mib->resolve_oid($_); }
I know the docs are tough, especially if you are unfamiliar with SNMP. The key is that respository, and precompiling the MIBs.

Happy hacking, and I apologize for lack of concrete code, etc.. I am pissed I didnt pull my code prior to losing the server :(

/* And the Creator, against his better judgement, wrote man.c */

In reply to Re: SNMP::MIB::Compiler ? by l2kashe
in thread SNMP::MIB::Compiler ? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.