Help with SNMP get_request

S

SP

The following code does not give me the expected rsult.

When I run snmpget froom the command line I get
"SNMPv2-SMI::enterprises.232.3.2.5.1.1.3.1.132 = STRING: "COMPAQ
BD07265A22 "

When I run the perl code I get the following:
<<<< OUTPUT >>>>
Session: Net::SNMP=HASH(0x85123b4)
Error:
OID: 1.3.6.1.4.1.232.3.2.5.1.1.3.1.132
Disk Info: HASH(0x8143750)


I'm just starting to use the NET::SNMP module and i'm not sure what I'm
doing wrong.

Thanks for the help
Sal

#---------------------------------------------------
my ($session, $error);
if ($o_snmp_ver eq "2c")
{
# SNMPv2 Login
($session, $error) = Net::SNMP->session
(
-hostname => $o_host,
-version => 2,
-community => $o_community,
);
}

print "Session: ",$session,"\n","Error: ",$error,"\n";

#Build the OID string
$oid_to_get = $drive_model_trgt . "." . $o_ctrl_num . "." .
$o_disk_num;

#Get disk status
if (!defined($disk_info[1] = $session->get_request($oid_to_get)))
{
$error_msg=$session->error;
print "ERROR - Target: ",$o_host,"\n";
print "Community: ",$o_community,"\n";
print "OID: ",$oid_to_get,"\n";
print "Error: ",$error_msg,"\n";
$session->close;
}
$session->close;

print "OID: ", $oid_to_get, "\n";
print "Disk Info: ",$disk_info[1], "\n";
---------------------------------------------------------------------
 
E

ethandbrown

Hi Sal--

Looks like the result is an array of hash references. When I don't
want to bother deciphering the docs on the return format, I just use
the Data::Dumper module, which prints the data structures in an nice
way.

Try:
use Data::Dumper;
....
print "Disk Info Structure", Dumper(\@disk_info);

Hope this helps,

--Ethan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top