While I was implementing a simple program I came accross with the following error:

Problem with session get request: The OBJECT IDENTIFIER value "ARRAY(0 +x942c50)" is expected in dotted decimal notation.

I tried to find online the reason that appears but not successfully. It is like no one has ever encounter this problem. Or maybe I can not find a relevant report at least.

The program is a very simple Net::SNMP->session request

my @info = split(/:/, $IP); # initiate snmp session ($session, $error) = Net::SNMP->session( -hostname => $info[0], -port => $info[1], -nonblocking => $boolean, -version => $version, -domain => $domain, -timeout => $seconds, -retries => $count, -maxmsgsize => $octets, -translate => $translate, -community => $community, ); if (!defined ($session)) { printf "Problem: %s.\n", $error; exit 1; } print Dumper(\$session);

I printed the $session with Dumper in order to possibly detect the error and I came across with something strange:

$VAR1 = \bless( { '_translate' => 0, '_security' => bless( { '_error' => undef, '_community' => 'public', '_version' => 0 }, 'Net::SNMP::Security::Comm +unity' ), '_transport_argv' => [ '-retries', '2', '-hostname', '127.0.0.1', '-port', '161', '-maxmsgsize', '1472', '-domain', 'udp/ipv4', '-timeout', '3' ], '_pdu' => undef, '_callback' => undef, '_nonblocking' => 0, '_version' => 0, '_transport' => bless( { '_dest_name' => '� +', '_max_msg_size' => 1472, '_sock_name' => '', '_timeout' => 3, '_error' => undef, '_sock_hostname' => '', '_dest_hostname' => '127.0 +.0.1', '_socket' => bless( \*Symb +ol::GEN0, 'IO::Socket' ), '_retries' => 2 }, 'Net::SNMP::Transport::IP +v4::UDP' ), '_error' => undef, '_context_engine_id' => undef, '_context_name' => undef, '_delay' => 0, '_discovery_queue' => [], '_hostname' => '127.0.0.1' }, 'Net::SNMP' );

The strange part is that although that IP and port at the -hostname and -port are read normally. But later on it appears like the characters have wrong format.

I noticed that here where I post the code you can not observe the funny characters, so I will try to describe them based on the location.

'_dest_name' => '�', '_sock_name' => '',

They appear on this two locations.

Has anyone ever encounter this problem? Any suggestions would be much appreciated.

Thank you in advance for your time and effort.

UPDATE: Thank you Perl Monks for your assistance and support. I wanted to post my solution just in case that someone else has the same problem with me.

This is a simple of SNMP get_request() taken from Net::SNMP.

The code is the following:

#! /usr/local/bin/perl use strict; use warnings; use Net::SNMP; use Data::Dumper; #use Net::SNMP qw (:snmp); my $OID_sysUpTime = '1.3.6.1.2.1.1.3.0'; my $OID_sysDescr = '1.3.6.1.2.1.1.1.0'; my @request; my ($session, $error) = Net::SNMP->session( -hostname => shift || 'localhost', -community => shift || 'public', ); if (!defined $session) { printf "ERROR: %s.\n", $error; exit 1; } #@request = ('1.3.6.1.2.1.1.3.0'); #push @request, '1.3.6.1.2.1.1.3.0'; #print Dumper(@request); push (@request, ($OID_sysDescr,$OID_sysUpTime)); my $result = $session->get_request( -varbindlist => [ @request ], ); if (!defined $result) { printf "ERROR: %s.\n", $session->error(); $session->close(); exit 1; } printf "The sysUpTime and sysDescr for host '%s' is %s and %s.\n", $session->hostname(), $result->{$OID_sysUpTime}, $result->{$OID_sysDescr}; $session->close(); exit 0;

My code had small differences from CPAN but something interesting to notice is to send less as possible SNMP get_request(). On my code I use an @array to put all the OID addresses together in on request.

I hope that will help someone else beginner like me in the future.


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.