M
milaus
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
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