in reply to SNMP::MIB::Compiler ?

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 */

Replies are listed 'Best First'.
Re: Re: SNMP::MIB::Compiler ?
by Anonymous Monk on Feb 28, 2003 at 15:03 UTC
    Thats a great help
    Thanks