SNMP module to query net-snmp



Hi all,
I'm writing a perl script to query linux snmpd daemon (net-snmp) and I'm
using SNMP module "The Perl5 'SNMP' Extension Module for the Net-SNMP
SNMP package".
I tried to start with very simple script, using the examples as
starting-point
(http://search.cpan.org/src/HARDAKER/SNMP-5.0301001/examples/)
But I can't figure out why my script doesn't work...

This are the script and its output:

#!/usr/bin/perl
use strict;
use warnings;
use SNMP;
my $host = '10.102.64.111';
my $community = 'public';
{
my $sess = new SNMP::Session (DestHost => $host,
Community => $community,
Retries => 1) || die "session doesn't work...\n";
my $oid = ".1.3.6.1.2.1.4.1.0";
my $cb = "3";
my ($result) = $sess->get(["$oid", "$cb"]) || 'get doesn\'t
work...';
print "result: $result\n";
}
### end of example-snmp.pl ###

[root@wi064111 ~]# ./example-snmp.pl
result: get doesn't work...

Instead, if I invoke 'snmpget' from the command line everything works
correctly ('snmpget' is the client side command of net-snmp package).

[root@wi064111 ~]# snmpget -c public -v 1 10.102.64.111
..1.3.6.1.2.1.4.1.0 IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)

Any ideas?
Thanks,
Marco
.



Relevant Pages

  • Re: Slightly [OT] Network Monitoring/Alerting tools
    ... Of course if your server is prone to running out of resources you should also be collecting that data via snmp with thresholds to notify you before you have an outage or at least graphing it so you'll understand the trends. ... We were able to use the monitor to look for ... Most of the common things you would want are already built in so you don't have to script them - or install scripts on all the clients. ...
    (Fedora)
  • [Full-disclosure] [ GLSA 200808-02 ] Net-SNMP: Multiple vulnerabilities
    ... Title: Net-SNMP: Multiple vulnerabilities ... snmpd and execution of arbitrary code in Perl applications using ... Net-SNMP is a collection of tools for generating and retrieving SNMP ... The SNMPv3 protocol uses a keyed-Hash Message Authentication Code ...
    (Full-Disclosure)
  • [ GLSA 200808-02 ] Net-SNMP: Multiple vulnerabilities
    ... Title: Net-SNMP: Multiple vulnerabilities ... snmpd and execution of arbitrary code in Perl applications using ... Net-SNMP is a collection of tools for generating and retrieving SNMP ... The SNMPv3 protocol uses a keyed-Hash Message Authentication Code ...
    (Bugtraq)
  • Re: SNMP Setup - where is snmpconf
    ... > have been following the mrtg instructions with a fair amount of success ... Typing snmpconf gives me the app's prompt ... ... Or perhaps net-snmp is not installed? ... SNMP is a protocol used for ...
    (linux.redhat.misc)
  • SNMPv3 Authentication Bypass - CVE-2008-0960
    ... I just finished testing my latest code, it's a patch for Net-SNMP 5.4.1.1 that allow you to exploit the CVE-2008-0960 for bypass the HMAC validation on SNMP v3. ...
    (Pen-Test)