Re: SNMP Perl module and MIB navigation

Wes Hardaker <[email protected]>
Newsgroups gmane.network.net-snmp.user
Organization Sparta
Message-ID <[email protected]>
>>>>> On Fri, 14 Aug 2009 16:30:40 -0400, Daniel Savard <[email protected]> said:

DS> Hello everyone,
DS> I am trying to convert notifications from a serie of MIB files I have. In
DS> fact, I need to read the MIB files and output couple of other files which
DS> content depends on the notifications and traps defined into the MIB files.
DS> Rather than writing my own MIB file parser, I tried to use the Perl SNMP
DS> module. However, I am not able to get the MIB files loaded and read
DS> appropriately. Whatever I am doing, it seems the information is not made
DS> available into the MIB hash (%MIB).

The perl interface can load notification information.  But rather than
describe that, can I suggest you use mib2c instead for doing your
conversion?  It's easier to use than writing a complete mib walker
yourself (it's written in perl, FYI).

# cat >> foo.conf << EOF
@open -@
@foreach $n notifications@
OID=$n.objectID
	TYPE=$n.type
	LABEL=$n.label
	DESCRIPTION=$n.description
	INCLUDED VARBINDS:
  @foreach $v varbinds@
		VARBIND: $v.objectID $v.type
  @end@
@end@
EOF

# mib2c -c foo.conf snmpTraps
...
OID=.1.3.6.1.6.3.1.1.5.3
        TYPE=
        LABEL=linkDown
        DESCRIPTION=A linkDown trap signifies that the SNMP entity, acting in
            an agent role, has detected that the ifOperStatus object for
            one of its communication links is about to enter the down
            state from some other state (but not from the notPresent
            state).  This other state is indicated by the included value
            of ifOperStatus.
        INCLUDED VARBINDS:
                VARBIND: .1.3.6.1.2.1.2.2.1.1 ASN_INTEGER
                VARBIND: .1.3.6.1.2.1.2.2.1.7 ASN_INTEGER
                VARBIND: .1.3.6.1.2.1.2.2.1.8 ASN_INTEGER
...


(set the MIBS environment variable to force load some other mibs)

See the mib2c.conf manual page for help on writing more using mib2c.
-- 
Wes Hardaker
Cobham Analytic Solutions

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.