Title: RE: Perl module parsing MIB structure -- barking up the wrong tree?

Thanks for the response Alex.

> It sounds like you want to pull out the VARIABLES line (v1) or OBJECTS
> line (v2+) from the MIB using the Perl module.

Yes, that's what I was thinking--it's a shame to have to duplicate the info somewhere other than the MIB file!

The intention was to allow the caller of my hypothetical module to send traps without needed to know all the OIDs of the variables that are sent with the trap, just pass in a trap number, and an array of parameters.

Thanks, I'll try out the code with the Perl debugger and see what I get...when I tried to view the Hash before (in the debugger), it gave me a never-ending stream of data (of all the loaded MIBs)!

Tom.

-----Original Message-----
From: Alex Burger [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 27, 2005 10:46 AM
To: Tom O'Brien
Cc: 'net-snmp-users@lists.sourceforge.net'
Subject: Re: Perl module parsing MIB structure -- barking up the wrong tree?


Hi Tom.

Tom O'Brien wrote:
> Hi all:
> I'm trying to write a Perl module (for my own use) based on the SNMP
> module distributed with Net-SNMP.
>
> What I'd like to do is based on a trap number and OID, look up a
> TRAP-TYPE (v1) definition, and determine what OIDs, data-types, and
> values that the trap requires.
>
> I'd then be able to build up a call to SNMP::TrapSession::trap() that
> would get all the required information directly from the MIB file,
> rather than hard-coding information already in the MIB into my code.
>
> My interface to the module would look something like:
> sendTrap($$@)
>         $ = enterprise OID of the trap to send
>         $ = specific trap to send
>         @ = array of parameters that are attached to the trap
>
> I haven't found examples of getting information out of the SNMP::MIB
> tied hash; is what I'm thinking of feasible at all?

It sounds like you want to pull out the VARIABLES line (v1) or OBJECTS
line (v2+) from the MIB using the Perl module.  Based on what I see in
the perl/SNMP/README file, I don't think it's possible.  There is no
hash entry for those variables.

Here is a bit of code that will pull some data from the hash for a
linkDown (.1.3.6.1.6.3.1.1.5.3) which may help you:

#!/usr/bin/perl
use SNMP;
$ENV{'MIBS'} = 'ALL';
&SNMP::initMib();

$a = '.1.3.6.1.6.3.1.1.5.3';
print qq/key:    $a\n
label:  $SNMP::MIB{$a}{label}\n
type:   $SNMP::MIB{$a}{type}\n
module: $SNMP::MIB{$a}{moduleID}\n\n"
/;

Are you trying to write a program to create test traps based on the MIB?

Alex

Reply via email to