Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

snmpget and compound MIB variables

27 views
Skip to first unread message

Alexander Shikoff

unread,
Sep 2, 2009, 4:14:44 PM9/2/09
to
Hello All!

Juniper Networks provides handy MIBs for monitoring Source/Destination
Class Usage: JUNIPER-SCU-MIB and JUNIPER-DCU-MIB.
After issuing snmpwalk for Juniper router I got:

# snmpwalk -v2c -c public -m+JUNIPER-SCU-MIB -M+../mrtg/MIBs/Juniper/9.5 br1-gdr jnxScuStats
JUNIPER-SCU-MIB::jnxScuStatsPackets.208.ipv4."from-UAIX" = Counter64: 3874095450
JUNIPER-SCU-MIB::jnxScuStatsPackets.208.ipv4."from-World" = Counter64: 6761075110
JUNIPER-SCU-MIB::jnxScuStatsBytes.208.ipv4."from-UAIX" = Counter64: 323892864678
JUNIPER-SCU-MIB::jnxScuStatsBytes.208.ipv4."from-World" = Counter64: 554254412101
JUNIPER-SCU-MIB::jnxScuStatsClName.208.ipv4."from-UAIX" = STRING: from-UAIX
JUNIPER-SCU-MIB::jnxScuStatsClName.208.ipv4."from-World" = STRING: from-World

snmpget works fine also, for example when I want to get only one variable:
# snmpget -v2c -c public -m+JUNIPER-SCU-MIB -M+../mrtg/MIBs/Juniper/9.5 br1-gdr jnxScuStatsBytes.208.ipv4.\"from-World\"
JUNIPER-SCU-MIB::jnxScuStatsBytes.208.ipv4."from-World" = Counter64: 554258204428

The main problem is how to get the same behavior with Perl interface?
I've tried the following code:

#!/usr/bin/perl -w
use strict;
use SNMP;

$ENV{'MIBDIRS'} = '/usr/local/share/snmp/mibs:/data/noc/mrtg/MIBs/Juniper/9.5';
$ENV{'MIBS'} = 'JUNIPER-SCU-MIB';

my $sess = new SNMP::Session(DestHost => 'br1-gdr', Community => 'public', Version => '2c' );
print $sess->get('jnxScuStatsBytes.208.ipv4."from-World"'), "\n";

But script returns error NOSUCHINSTANCE.
Debugging shows that jnxScuStatsBytes.208.ipv4."from-World" is not
converted to OID correctly:
# ./test.pl
trace: netsnmp_ds_set_boolean(): default_store.c, 208:
netsnmp_ds_set_boolean: Setting LIB:4 = 0/False
trace: _snmp_build(): snmp_api.c, 2937:
snmp_send: Building SNMPv2 message...
trace: _snmp_build(): snmp_api.c, 2940:
dumph_send: GET
trace: snmp_pdu_realloc_rbuild(): snmp_api.c, 3308:
snmp_pdu_realloc_rbuild: starting
trace: snmp_pdu_realloc_rbuild(): snmp_api.c, 3323:
dumph_send: VarBind
trace: snmp_realloc_rbuild_var_op(): snmp.c, 341:
dumph_send: Value
dumpx_send: 05 00
dumpv_send: NULL
trace: snmp_realloc_rbuild_var_op(): snmp.c, 442:
dumph_send: Name
dumpx_send: 06 11 2B 06 01 04 01 94 4C 03 10 01 01 01 05 81
50 00 00
dumpv_send: ObjID: jnxScuStatsBytes.208.0.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]

Any help is kindly appreciated! Thanks.

--
MINO-RIPE

------------------------------------------------------------------------------
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
Net-snm...@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Dave Shield

unread,
Sep 3, 2009, 5:15:24 AM9/3/09
to
2009/9/2 Alexander Shikoff <mino...@crete.org.ua>:

> $ENV{'MIBDIRS'} = '/usr/local/share/snmp/mibs:/data/noc/mrtg/MIBs/Juniper/9.5';
> $ENV{'MIBS'} = 'JUNIPER-SCU-MIB';

It would probably be sensible to insert a '+' before these two values,
as you did with the command-line arguments.


> my $sess = new SNMP::Session(DestHost => 'br1-gdr', Community => 'public', Version => '2c' );
> print $sess->get('jnxScuStatsBytes.208.ipv4."from-World"'), "\n";
>
> But script returns error NOSUCHINSTANCE.
> Debugging shows that jnxScuStatsBytes.208.ipv4."from-World" is not
> converted to OID correctly:

What happens if you try replacing:

a) "ipv4" with the numeric enumeration value

b) "from-World" with the equivalent list of numeric OIDs
(10.102.114.111.199.45.87.111.114.108.100)

c) both of the above

?

Dave

Alexander Shikoff

unread,
Sep 3, 2009, 7:09:01 AM9/3/09
to
Hi Dave,

On Thu, Sep 03, 2009 at 10:09:35AM +0100, Dave Shield wrote:
> 2009/9/2 Alexander Shikoff <mino...@crete.org.ua>:
> > $ENV{'MIBDIRS'} = '/usr/local/share/snmp/mibs:/data/noc/mrtg/MIBs/Juniper/9.5';
> > $ENV{'MIBS'} = 'JUNIPER-SCU-MIB';
>
> It would probably be sensible to insert a '+' before these two values,
> as you did with the command-line arguments.

It loads MIB normally, jnxScuStatsBytes is normally converted by &SNMP::translateObj
to numeric OID.

>
> > my $sess = new SNMP::Session(DestHost => 'br1-gdr', Community => 'public', Version => '2c' );
> > print $sess->get('jnxScuStatsBytes.208.ipv4."from-World"'), "\n";
> >
> > But script returns error NOSUCHINSTANCE.
> > Debugging shows that jnxScuStatsBytes.208.ipv4."from-World" is not
> > converted to OID correctly:
>
> What happens if you try replacing:
>
> a) "ipv4" with the numeric enumeration value

print $sess->get('jnxScuStatsBytes.208.1."from-World"'), "\n";

# ./test.pl
NOSUCHINSTANCE



> b) "from-World" with the equivalent list of numeric OIDs
> (10.102.114.111.199.45.87.111.114.108.100)

^^^^^^^ here should be 109, not 199
print $sess->get('jnxScuStatsBytes.208.ipv4.10.102.114.111.109.45.87.111.114.108.100'), "\n";

# ./test.pl
NOSUCHINSTANCE

> c) both of the above

print $sess->get('jnxScuStatsBytes.208.1.10.102.114.111.109.45.87.111.114.108.100'), "\n";
# ./test.pl
570840089787
Now it works.

Net-SNMP command line tools work normally in any case but SNMP perl interface
does not.

--
MINO-RIPE

Dave Shield

unread,
Sep 3, 2009, 7:22:40 AM9/3/09
to
2009/9/3 Alexander Shikoff <mino...@crete.org.ua>:
>> =A0 =A0c) =A0 both of the above
> print $sess->get('jnxScuStatsBytes.208.1.10.102.114.111.109.45.87.111.114=

.108.100'), "\n";
> # ./test.pl
> 570840089787
> Now it works.

OK - so the problem is that the perl API doesn't interpret enumerations or
string index values. I've logged this in the tracker system as bug #28498=
67

Dave

---------------------------------------------------------------------------=
---
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 =

0 new messages