3

Is there a simple way/module to map snmp(MIB) strings to OIDs in Perl?

E.g. I start with "sysUpTime.0" and get "1.3.6.1.2.1.1.3.0". As far as I can see, Net::SNMP expects you to have them already mapped.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Sec
  • 7,059
  • 6
  • 31
  • 58

1 Answers1

5

You can use NetSNMP::OID to do the conversion.

use NetSNMP::OID;

my $oid = NetSNMP::OID->new('sysUpTime.0');

NetSNMP::OID is part of the Net-SNMP project, not to be confused with the Net::SNMP module.

daotoad
  • 26,689
  • 7
  • 59
  • 100
  • NetSNMP::OID doesn't compile for me, and at least for ubuntu I can't find a package. – Sec Mar 12 '10 at 16:41
  • @Sec: you can install directly from CPAN; there are posts about this on SO with more information if you have questions about this process. – Ether Mar 12 '10 at 17:15
  • I _was_ using "perl -MCPAN -e 'install NetSNMP::OID'". – Sec Mar 12 '10 at 18:07
  • 2
    Try downloading Net-SNMP from sourceforge and using it. Worked like a charm for me with Ubuntu 8.4. – daotoad Mar 12 '10 at 18:34