Net-SNMP, community !~ public, JBOSS-4.0.4.GA

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
 
H

Hans Jørgen Jakobsen

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
Do you get the community transfered from the command line to the Net::SNMP
module?
Try: ./myscript.pl wi064111:11112 anythingButPublic 1.2.3.4.1.2

The examples I found at CPAN has a somewhat other syntax than you uses.

Have you considered use the perlmodule from net-snmp. Net-snmp might be
what you are using through you command line utilities.
(http://net-snmp.sourceforge.net/)
Net::SNMP is not at all the same as net-snmp!!
/hjj
 
M

milaus

Il Wed, 30 Aug 2006 16:35:23 +0000, Hans Jørgen Jakobsen ha scritto:
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 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
Do you get the community transfered from the command line to the Net::SNMP
module?
Try: ./myscript.pl wi064111:11112 anythingButPublic 1.2.3.4.1.2

The examples I found at CPAN has a somewhat other syntax than you uses.

Have you considered use the perlmodule from net-snmp. Net-snmp might be
what you are using through you command line utilities.
(http://net-snmp.sourceforge.net/)
Net::SNMP is not at all the same as net-snmp!!
/hjj

Off course Net::SNMP is not the same as net-snmp, I thought it was
obvious and I didn't specify it, sorry :)
But perhaps there is a little misunderstanding, maybe due to the fact
that I'm a linux sysadmin, not a perl programmer :)
myscript.pl cannot work on port 11112 with a !'public' community.
myscript.pl should work on port 11112 with community 'public' and it does.
myscript.pl should work on port 11212 with community 'q3lrdjb' and it
doesn't.
But if your purpose was only debugging, here is the output for your test:
[root@wi064111 ~]# ./myscript.pl wi064111:11112 anythingButPublic
1.2.3.4.1.2 Hostname: wi064111:11112 Community: anythingButPublic OID:
1.2.3.4.1.2 request error: No response from remote host 'wi064111' at
../myscript.pl line 10.

It still stop at the get_request line and not at the Net::SNMP->session
line...

Finally, I've considered using the perlmodule from net-snmp, but I tried
NET::SNMP because it's better documented and I'm not so good with perl.
Moreover in NET:SNMP synopsis you can read:
"The Net::SNMP module implements an object oriented interface to the
Simple Network Management Protocol. Perl applications can use the module
to retrieve or update information on a remote host using the SNMP
protocol. The module supports SNMP version-1, SNMP version-2c
(Community-Based SNMPv2), and SNMP version-3."
So, in my opinion, it should work to query any snmp agent... and this is
the reason of my doubt: the problem is NET::SNMP perlmodule or JBOSS snmp
agent?

As for the example syntax, it's only a simplified one, my bigger script
has exactly CPAN-example syntax, but the result is the same...

I'll try to understand how to use perlmodule from net-snmp, but I'll
remain with my starting doubt...

Thanks,
Marco
 

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,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top