M
milaus
Hi all,
sorry for mistakes I did in previous posting. I hope to do better now,
starting from the subject
Since the last JBOSS version (4.0.4.GA), a SNMP-agent has been added to
the application server.
I'm writing a perl-script to monitor JBOSS via snmp, by using Net::SNMP
5.20 perl module.
The problem is that if I set a community different from 'public',
snmp-queries done via NET::SNMP module on JBOSS snmp-agent don't work.
While snmp-queries done via 'snmpget' command (from command line) on JBOSS
snmp-agent work perfecty with any community.
I worte a little script to isolate the problem:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SNMP;
my ($session,$error) = Net::SNMP->session(Hostname => $ARGV[0],
Community => $ARGV[1]);
die "session error: $error" unless ($session);
printf("Hostname: %s Community: %s OID: %s\n", $ARGV[0], $ARGV[1], $ARGV[2]);
my $result = $session->get_request("$ARGV[2]");
die "request error: ".$session->error unless (defined $result);
$session->close;
print "OID requested: ".$result->{"$ARGV[2]"}."\n";
### myscript.pl end ###
I tested the problem in this scenario:
- host wi064111 running CentOS 4.3
-- JBOSS running snmp-adaptor.sar with community 'public' on port 11112
-- JBOSS running snmp-adaptor.sar with community 'q3lrcdjb' on port 11212
-- snmpd daemon running on port 161 (tested with both previous communities)
The result of my tests is:
1) 'snmpget' command works perfectly quering both snmpd daemon and JBOSS
snmp-agent, with any community:
[root@wi064111 ~]# snmpget -c public -v 1 10.102.64.111:161 .1.3.6.1.2.1.4.1.0
IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)
[root@wi064111 ~]# snmpget -c q3lrcdjb -v 1 10.102.64.111:161
..1.3.6.1.2.1.4.1.0
IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)
[root@wi064111 ~]# snmpget -c public -v 1 10.102.64.111:11112 1.2.3.4.1.2
iso.2.3.4.1.2 = Gauge32: 92686392
[root@wi064111 ~]# snmpget -c q3lrcdjb -v 1 10.102.64.111:11212
1.2.3.4.1.2
iso.2.3.4.1.2 = Gauge32: 94004080
2) myscript.pl works perfectly quering snmpd daemon, with any community:
[root@wi064111 ~]# ./myscript.pl wi064111:161 public 1.3.6.1.2.1.4.1.0
Hostname: wi064111:161 Community: public OID: 1.3.6.1.2.1.4.1.0
OID requested: 2
[root@wi064111 ~]# ./myscript.pl wi064111:161 q3lrcdjb 1.3.6.1.2.1.4.1.0
Hostname: wi064111:161 Community: q3lrcdjb OID: 1.3.6.1.2.1.4.1.0
OID requested: 2
3) myscript.pl queries on JBOSS snmp-agent work only with community
'public':
[root@wi064111 ~]# ./myscript.pl wi064111:11112 public 1.2.3.4.1.2
Hostname: wi064111:11112 Community: public OID: 1.2.3.4.1.2
OID requested: 91884232
[root@wi064111 ~]# ./myscript.pl wi064111:11212 q3lrcdjb 1.2.3.4.1.2
Hostname: wi064111:11212 Community: q3lrcdjb OID: 1.2.3.4.1.2
request error: Bad incoming community [public] at ./myscript.pl line 10.
************************************************************************
THIS IS THE ERROR I GET.
Now, NET::SNMP module seems to be ok because works perfectly with snmpd
daemon. On the other side, JBOSS snmp-agent seems to be ok because answers
perfectly to snmpget queries.
But NET::SNMP module with JBOSS snmp-agent doesn'work correctly. Moreover
the error is caused by $session->get_request line, and not by
Net::SNMP->session line. It seems like JBOSS snmp-agent would expect a new
authentication every request.
Could the error be in NET::SNMP module implementation?
Thanks to everyone who just read the whole post,
Marco
sorry for mistakes I did in previous posting. I hope to do better now,
starting from the subject
Since the last JBOSS version (4.0.4.GA), a SNMP-agent has been added to
the application server.
I'm writing a perl-script to monitor JBOSS via snmp, by using Net::SNMP
5.20 perl module.
The problem is that if I set a community different from 'public',
snmp-queries done via NET::SNMP module on JBOSS snmp-agent don't work.
While snmp-queries done via 'snmpget' command (from command line) on JBOSS
snmp-agent work perfecty with any community.
I worte a little script to isolate the problem:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SNMP;
my ($session,$error) = Net::SNMP->session(Hostname => $ARGV[0],
Community => $ARGV[1]);
die "session error: $error" unless ($session);
printf("Hostname: %s Community: %s OID: %s\n", $ARGV[0], $ARGV[1], $ARGV[2]);
my $result = $session->get_request("$ARGV[2]");
die "request error: ".$session->error unless (defined $result);
$session->close;
print "OID requested: ".$result->{"$ARGV[2]"}."\n";
### myscript.pl end ###
I tested the problem in this scenario:
- host wi064111 running CentOS 4.3
-- JBOSS running snmp-adaptor.sar with community 'public' on port 11112
-- JBOSS running snmp-adaptor.sar with community 'q3lrcdjb' on port 11212
-- snmpd daemon running on port 161 (tested with both previous communities)
The result of my tests is:
1) 'snmpget' command works perfectly quering both snmpd daemon and JBOSS
snmp-agent, with any community:
[root@wi064111 ~]# snmpget -c public -v 1 10.102.64.111:161 .1.3.6.1.2.1.4.1.0
IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)
[root@wi064111 ~]# snmpget -c q3lrcdjb -v 1 10.102.64.111:161
..1.3.6.1.2.1.4.1.0
IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)
[root@wi064111 ~]# snmpget -c public -v 1 10.102.64.111:11112 1.2.3.4.1.2
iso.2.3.4.1.2 = Gauge32: 92686392
[root@wi064111 ~]# snmpget -c q3lrcdjb -v 1 10.102.64.111:11212
1.2.3.4.1.2
iso.2.3.4.1.2 = Gauge32: 94004080
2) myscript.pl works perfectly quering snmpd daemon, with any community:
[root@wi064111 ~]# ./myscript.pl wi064111:161 public 1.3.6.1.2.1.4.1.0
Hostname: wi064111:161 Community: public OID: 1.3.6.1.2.1.4.1.0
OID requested: 2
[root@wi064111 ~]# ./myscript.pl wi064111:161 q3lrcdjb 1.3.6.1.2.1.4.1.0
Hostname: wi064111:161 Community: q3lrcdjb OID: 1.3.6.1.2.1.4.1.0
OID requested: 2
3) myscript.pl queries on JBOSS snmp-agent work only with community
'public':
[root@wi064111 ~]# ./myscript.pl wi064111:11112 public 1.2.3.4.1.2
Hostname: wi064111:11112 Community: public OID: 1.2.3.4.1.2
OID requested: 91884232
[root@wi064111 ~]# ./myscript.pl wi064111:11212 q3lrcdjb 1.2.3.4.1.2
Hostname: wi064111:11212 Community: q3lrcdjb OID: 1.2.3.4.1.2
request error: Bad incoming community [public] at ./myscript.pl line 10.
************************************************************************
THIS IS THE ERROR I GET.
Now, NET::SNMP module seems to be ok because works perfectly with snmpd
daemon. On the other side, JBOSS snmp-agent seems to be ok because answers
perfectly to snmpget queries.
But NET::SNMP module with JBOSS snmp-agent doesn'work correctly. Moreover
the error is caused by $session->get_request line, and not by
Net::SNMP->session line. It seems like JBOSS snmp-agent would expect a new
authentication every request.
Could the error be in NET::SNMP module implementation?
Thanks to everyone who just read the whole post,
Marco