Problem with session get request: The OBJECT IDENTIFIER value "ARRAY(0x942c50)" is expected in dotted decimal notation.
####
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);
####
$VAR1 = \bless( {
'_translate' => 0,
'_security' => bless( {
'_error' => undef,
'_community' => 'public',
'_version' => 0
}, 'Net::SNMP::Security::Community' ),
'_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( \*Symbol::GEN0, 'IO::Socket' ),
'_retries' => 2
}, 'Net::SNMP::Transport::IPv4::UDP' ),
'_error' => undef,
'_context_engine_id' => undef,
'_context_name' => undef,
'_delay' => 0,
'_discovery_queue' => [],
'_hostname' => '127.0.0.1'
}, 'Net::SNMP' );
####
'_dest_name' => '�',
'_sock_name' => '',
####
#! /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;