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