please helpme: Net-SNMP-5.2.0 module

M

milaus

Hi all,
this is my first post to this ng, sorry if my question appears stupid or
misplaced.
I'm writing a perl script to monitor some JBOSS variables via SNMP, but
I've a problem passing a community string different from 'public'.
I'll try to explain, this is my environment:
- hostname: wi064111
- on port 11112 a snmp-agent listens with community 'public'
- on port 11212 a snmp-agent listens with community 'q3lrcdjb'

By using a snmp-get (from another host) everything works:

[root@cst003 ~]# snmpget -c public -v 1 wi064111:11112 1.2.3.4.1.2
iso.2.3.4.1.2 = Gauge32: 88502720
[root@cst003 ~]#
[root@cst003 ~]# snmpget -c q3lrcdjb -v 1 wi064111:11212 1.2.3.4.1.2
iso.2.3.4.1.2 = Gauge32: 92236344

By using this perl script, I got the problem:
##############################################
# Script-begin
#
#!/usr/bin/perl
use Net::SNMP;
# requires a hostname a community string and a port as its arguments
($session,$error) = Net::SNMP->session(Hostname => $ARGV[0],
Community => $ARGV[1],
Port => $ARGV[2]);
die "session error: $error" unless ($session);
printf("Port: %s Community: %s Hostname: %s\n", $ARGV[2], $ARGV[1],$ARGV[0]);
$result = $session->get_request("1.2.3.4.1.2");
die "request error:".$session->error unless (defined $result);
$session->close; print "Free Memory: ".$result->{"1.2.3.4.1.2"}."\n";
#
# Script-end
###########################

This are the output with the two different community strings:

[root@wi064111 ~]# ./myscript.pl wi064111 public 11112
Port: 11112 Community: public Hostname: wi064111
Free Memory: 87953768

[root@wi064111 ~]# ./myscript.pl wi064111 q3lrcdjb 11212
Port: 11212 Community: q3lrcdjb Hostname: wi064111
request error: Bad incoming community [public] at ./aaa.pl line 18.

It sounds like $session->get_request method doesn't care about the
community string I've set.

Is it possbile that a perl module at version 5.2 contains such a bug or am
I doing some mistakes?

Thanks to everyone that just read the wole post :)
Many thanks to everyone that can help me :))

Ing. Marco Betti
RHCE RHEL4 id 804006512121056
 
D

Dr.Ruud

milaus schreef:
this is my first post to this ng, sorry if my question appears stupid
or misplaced.

Don't multi-post.

Improve the quality of the Subject, maybe:
Net-SNMP, community !~ public

Your script doesn't have "use warnings, use strict;".
Have you read the Posting Guidelines? They are posted here twice a week.
 

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

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top