Re: SNMP module to query net-snmp
- From: milaus <m.REMOVEbetti@xxxxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 16:50:19 +0200
Il Thu, 31 Aug 2006 14:47:39 +0200, Dr.Ruud ha scritto:
milaus schreef:
my ($result) = $sess->get(["$oid", "$cb"]) || 'get doesn\'t
work...';
I checked the SNMP-documentation, and I don't think that ["$oid", "$cb"]
is one of the "Acceptable variable fomats".
Maybe you need to use SNMP::VarList. Read also `perldoc -q always`.
The "|| 'get doesn\'t work...'" looks strange, I would change that to
or die "get doesn't work: ". $sess->ErrorStr ;
While testing, I would also do an $SNMP::verbose = 1 or $SNMP::debugging
= 1 at the start.
In the trouble shooting section of `perldoc SNMP` it says:
"If you cannot resolve the problem you can post to
news:comp.lang.perl.modules or net-snmp-users(AT)lists.sourceforge.net
please give sufficient information to analyze the problem (OS type,
versions for OS/Perl/UCD/compiler, complete error output, etc.)"
So there is a mailing list net-snmp-users@xxxxxxxxxxxxxxxxxxxxx
with an archive at
http://sourceforge.net/mailarchive/forum.php?forum_id=4959
Thank You for your answer and advices,
I'm new with perl and I don't know a lot of thing and off course I should
spend more time reading documentation... but, as you can imagine, when
everything you read is new you can't catch any detail as if you were
already used with the topic.
Anyway, I solved the problem, the main point was that "Version" field has
to be specified when calling "new SNMP::Session(DestHost... ". But in
official CPAN snmp module example, Version field was not used!! This is
the example on CPAN:
...
$sess = new SNMP::Session(DestHost => localhost, Community => public);
...
Only to be complete, my working little example is:
[root@wi064111 ~]# cat example-snmp.pl
#!/usr/bin/perl
use strict;
use warnings;
use SNMP;
my $host = $ARGV[0];
my $community = $ARGV[1];
my $OID = $ARGV[2];
my $porta = $ARGV[3];
my $versione = '2c';
my $sess = new SNMP::Session (DestHost => $host, Community => $community, Version => '2c', RemotePort => $porta );
my $val = $sess->get($OID);
print $val . "\n";
And this is the output, looking for ipForwarding parameter:
[root@wi064111 ~]# ./example-snmp.pl wi064111 public 1.3.6.1.2.1.4.1
2
Or, quering JBOSS-4.0.4.GA snmp agent looking for VM freeMemory:
[root@wi064111 ~]# ./example-snmp.pl wi064111 q3lrcdjb 1.2.3.4.1.2 11212
90081120
Bye,
Marco
.
- Follow-Ups:
- Re: SNMP module to query net-snmp
- From: Dr.Ruud
- Re: SNMP module to query net-snmp
- References:
- SNMP module to query net-snmp
- From: milaus
- Re: SNMP module to query net-snmp
- From: Dr.Ruud
- SNMP module to query net-snmp
- Prev by Date: Re: Hi Guys !
- Next by Date: Re: SNMP module to query net-snmp
- Previous by thread: Re: SNMP module to query net-snmp
- Next by thread: Re: SNMP module to query net-snmp
- Index(es):