in reply to ERROR: The OBJECT IDENTIFIER value "ARRAY(0x1b80628)" is expected in dotted decimal notation.

G'day thanos1983,

[Disclaimer: I'm not a user of Net::SNMP. The following information just comes from that module's documentation.]

That problem seems to be related to the value of the -varbindlist argument in a call to get_request() (or a related method, e.g. get_next_request()).

Have you shown the entirety of the error message? Was there any reference to the file or line number that generated that error? Without that sort of information, it's difficult to track down the problem remotely.

Have a look in Net::SNMP::get_request() for information about "OBJECT IDENTIFIERs" and the -varbindlist argument. There's also example code here.

See also the EXAMPLES section which has a lot more sample code.

-- Ken

Replies are listed 'Best First'.
Re^2: SNMP get request error
by thanos1983 (Parson) on Mar 22, 2014 at 18:27 UTC

    To: Ken,

    Thanks Ken, for your advices. You gave the idea of creating a small example and apply my code in order to find the real problem.

    I has an extra "\" at the point:

    push (@request, ($sysDescr,$sysUpTime)); $output = $session->get_request( -varbindlist => [\@request] , );

    When I removed the "\" everything worked perfectly

    Well the problem is that I do not exactly understand the reference part from CPAN where it says:

    "This list is passed to the method as an array reference using the -varbindlist argument."

    Thank you for your time and effore regarding my query. Since I am begginer I have so many questions and so many errors that I can not understand fast.

      "Since I am begginer I have so many questions and so many errors that I can not understand fast."

      I recommend you read "Perl introduction for beginners".

      You haven't shown enough of your test script but, if you're using

      push (@request, ($sysDescr,$sysUpTime));

      to create the @request array, that document will show you a better way:

      my @request = ($sysDescr, $sysUpTime);

      Perl will tell you about many of the problems in your code if you ask it to. Often these problems are the result of simple typos and have nothing to do with your proficiency with the language. Just add these two lines at the top of all your scripts (as I always do):

      use strict; use warnings;

      If you're having difficulties understanding the short messages that are produced by those, you can add this (although I'd advise against leaving that line in production code):

      use diagnostics;

      Another useful one, if your script is performing any I/O, is this (which I often use):

      use autodie;

      All of those are documented in Pragmas.

      "Well the problem is that I do not exactly understand the reference part ..."

      I recommend you read "Perl references short introduction".

      Specifically with [\@request], you're taking a reference to @request (i.e. \@request); then you create an anonymous array (with [...]) whose only element is an array reference. By removing the '\' (i.e. [@request]), you create an anonymous array whose elements are the values in @request.

      Another way of doing this would have been to remove the brackets instead of the backslash (i.e. change [\@request] to \@request). However, there's a subtle difference: [...] creates a new array reference; \@array creates a reference to an existing array. The following script may help in understanding this.

      #!/usr/bin/env perl -l use strict; use warnings; my @array = (1, 2, 3); my $array_ref_1 = \@array; my $array_ref_2 = [@array]; my $array_ref_3 = [1, 2, 3]; my $array_ref_ref = [\@array]; use Data::Dumper; print '*** $array_ref_1 = \@array ***'; print Dumper $array_ref_1; print '*** $array_ref_2 = [@array] ***'; print Dumper $array_ref_2; print '*** $array_ref_3 = [1, 2, 3] ***'; print Dumper $array_ref_3; print '*** $array_ref_ref = [\@array] ***'; print Dumper $array_ref_ref; my $array_ref_1_new = \@array; my $array_ref_2_new = [@array]; my $array_ref_3_new = [1, 2, 3]; print "\n"; print 'SAME: $array_ref_1 and $array_ref_1_new'; print "SAME: $array_ref_1 and $array_ref_1_new"; print "\n"; print 'DIFF: $array_ref_2 and $array_ref_2_new'; print "DIFF: $array_ref_2 and $array_ref_2_new"; print "\n"; print 'DIFF: $array_ref_3 and $array_ref_3_new'; print "DIFF: $array_ref_3 and $array_ref_3_new"; print "\n"; print 'SAME: $array_ref_1 and $array_ref_1_new and $array_ref_ref->[0] +'; print "SAME: $array_ref_1 and $array_ref_1_new and $array_ref_ref->[0] +";

      Output:

      *** $array_ref_1 = \@array *** $VAR1 = [ 1, 2, 3 ]; *** $array_ref_2 = [@array] *** $VAR1 = [ 1, 2, 3 ]; *** $array_ref_3 = [1, 2, 3] *** $VAR1 = [ 1, 2, 3 ]; *** $array_ref_ref = [\@array] *** $VAR1 = [ [ 1, 2, 3 ] ]; SAME: $array_ref_1 and $array_ref_1_new SAME: ARRAY(0x7fa0f202a628) and ARRAY(0x7fa0f202a628) DIFF: $array_ref_2 and $array_ref_2_new DIFF: ARRAY(0x7fa0f2029c68) and ARRAY(0x7fa0f210e2a8) DIFF: $array_ref_3 and $array_ref_3_new DIFF: ARRAY(0x7fa0f2029d40) and ARRAY(0x7fa0f20ca2f0) SAME: $array_ref_1 and $array_ref_1_new and $array_ref_ref->[0] SAME: ARRAY(0x7fa0f202a628) and ARRAY(0x7fa0f202a628) and ARRAY(0x7fa0 +f202a628)

      -- Ken

        To: Ken,

        Sorry for the late reply I just got caught by something argent.

        Wow, thanks a lot! The analysis was in depth and very thorough! I had a small confusion about the arrays I only the basics but know I have a more complete idea. I will go through all of your recommendation trying to get the most out of this opportunity.

        I will try to implement both:

        use autodie; use diagnostics;

        In order to see what happens with some pieces of code and observe the output. I guess is the only way of learning through experimentation.

        Again thank you for your time and effort to assist me and guide me it was useful for me.

        BR, Thanos