2 Replies Latest reply on Sep 20, 2006 10:23 AM by davide pasquero

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

    davide pasquero Newbie

      Hi all,
      I'm writing a perl-script to monitor JBOSS-4.0.4.GA 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:

      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);
      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 .
      IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)

      [root@wi064111 ~]# snmpget -c q3lrcdjb -v 1
      IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)

      [root@wi064111 ~]# snmpget -c public -v 1
      iso. = Gauge32: 92686392

      [root@wi064111 ~]# snmpget -c q3lrcdjb -v 1
      iso. = Gauge32: 94004080

      2) myscript.pl works perfectly quering snmpd daemon, with any community:

      [root@wi064111 ~]# ./myscript.pl wi064111:161 public
      Hostname: wi064111:161 Community: public OID:
      OID requested: 2

      [root@wi064111 ~]# ./myscript.pl wi064111:161 q3lrcdjb
      Hostname: wi064111:161 Community: q3lrcdjb OID:
      OID requested: 2

      3) myscript.pl queries on JBOSS snmp-agent work only with community

      [root@wi064111 ~]# ./myscript.pl wi064111:11112 public
      Hostname: wi064111:11112 Community: public OID:
      OID requested: 91884232

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

      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,

      ######## Listing of /jboss/admjboss-4.0.4.GA/jboss-4.0.4.GA/server/part02node01/deploy/snmp-adaptor.sar/META-INF/jboss-service.xml ##########
      <?xml version="1.0" encoding="UTF-8"?>
       <mbean code="org.jboss.jmx.adaptor.snmp.trapd.TrapdService"
       <attribute name="Port">1162</attribute>
       <!-- The SNMP adaptor MBean -->
       <mbean code="org.jboss.jmx.adaptor.snmp.agent.SnmpAgentService"
       <attribute name="RequestHandlerClassName">org.jboss.jmx.adaptor.snmp.agent.RequestHandlerImpl</attribute>
       <attribute name="RequestHandlerResName">/attributes.xml</attribute>
       <attribute name="TrapFactoryClassName">org.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport</attribute>
       <attribute name="NotificationMapResName">/notifications.xml</attribute>
       <attribute name="ManagersResName">/managers.xml</attribute>
       <attribute name="HeartBeatPeriod">0</attribute>
       <attribute name="Port">1161</attribute>
       <attribute name="DynamicSubscriptions">false</attribute>
       <attribute name="WriteCommunity">q3lwcdjb</attribute>
       <attribute name="ReadCommunity">q3lrcdjb</attribute>
       <attribute name="SubscriptionList">
       <!-- Monitor events from SNMP adaptor itself -->
       <mbean name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor">
       <notification type="jboss.snmp.agent.coldstart"/>
       <!-- Monitor timer for heartbeat events -->
       <mbean name="jboss.jmx:name=SnmpAgent,service=timer,type=heartbeat">
       <notification type="jboss.snmp.agent.heartbeat"/>
       <depends optional-attribute-name="TimerName">
       <mbean code="javax.management.timer.Timer"
       <!-- Defines the system information as specified in rfc-1213
       iso.org.dod.internet.mgmt.mib-2.system.* -->
       <mbean code="org.jboss.jmx.adaptor.snmp.system.MIB2SystemGroupService"
       <attribute name="SysLocation">In The Matrix</attribute>
       <attribute name="SysDescr">Central Computer</attribute>
       <attribute name="SysContact">Agent Smith</attribute>
       <depends optional-attribute-name="SnmpAgent">

      ########### listing of /jboss/admjboss-4.0.4.GA/jboss-4.0.4.GA/server/part02node01/deploy/snmp-adaptor.sar/attributes.xml ###########

      <?xml version="1.0"?>
       <mbean name="jboss.system:type=ServerInfo" oid-prefix=".">
       <attribute name="ActiveThreadCount" oid=".1"/>
       <attribute name="FreeMemory" oid=".2"/>
       <attribute name="MaxMemory" oid=".3"/>
       <attribute name="TotalMemory" oid=".10"/>
       <mbean name="jboss.system:service=ThreadPool">
       <attribute name="QueueSize" oid="."/>
       <attribute name="MaximumQueueSize" oid="."/>
       <mbean name="jboss.web:name=http-,type=GlobalRequestProcessor">
       <attribute name="requestCount" oid="."/>
       <mbean name="jboss:service=TransactionManager">
       <attribute name="CommitCount" oid="."/>
       <attribute name="RollbackCount" oid="."/>
       <attribute name="TransactionCount" oid="."/>
       <mbean name="jboss.jca:name=DefaultDS,service=ManagedConnectionPool" oid-prefix=".">
       <attribute name="InUseConnectionCount" oid=".9"/>
       <mbean name="jboss.jmx:name=SnmpAgent,service=MIB2SystemGroup" oid-prefix=".">
       <attribute name="SysDescr" oid=".1" mode="rw"/> <!-- can be modified over snmp -->
       <attribute name="SysObjectId" oid=".2"/>
       <attribute name="SysUpTime" oid=".3"/>
       <attribute name="SysContact" oid=".4"/>
       <attribute name="SysName" oid=".5"/>
       <attribute name="SysLocation" oid=".6"/>
       <attribute name="SysServices" oid=".7"/>

        • 1. Re: Net-SNMP, community !~ public, JBOSS-4.0.4.GA
          Heiko Rupp Master

          Can you do me a favour and open a JIRA issue for this?

          • 2. Re: Net-SNMP, community !~ public, JBOSS-4.0.4.GA
            davide pasquero Newbie

            I solved the problem by changing perl module.
            The perl module to be used is SNMP.
            As CPAN states:
            "SNMP - The Perl5 'SNMP' Extension Module for the Net-SNMP SNMP package."
            The "core" of my perl script now is:

            my %snmp_server = (
             hostname => $host,
             communit => $opt{'c'} || 'public',
             version => '2c',
             port => $opt{'p'},
             FreeMemory => $cfg->param('FreeMemory') || '',
             MaximumQueueSize => $cfg->param('MaximumQueueSize') || '',
             MaxMemory => $cfg->param('MaxMemory') || '',
             QueueSize => $cfg->param('QueueSize') || '',
             TotalMemory => $cfg->param('TotalMemory') || ''
            my $sess = new SNMP::Session (DestHost => $snmp_server{hostname},
             Community => $snmp_server{community},
             Version => $snmp_server{version},
             RemotePort => $snmp_server{port} );
            if ( !($sess) ) {
             printf( "ERROR: can't contact $snmp_server{hostname}\n" );
             exit 1;
            my @result = ( $sess->get($snmp_server{FreeMemory}), $sess->get($snmp_server{TotalMemory}),
             $sess->get($snmp_server{MaxMemory}), $sess->get($snmp_server{QueueSize}),
             $sess->get($snmp_server{MaximumQueueSize}) );
            if ( !(@result) ) {
             printf( "ERROR: can't contact $snmp_server{hostname}\n" );
             exit 1;

            Nothing changes in JBoss config that I posted in my first message.
            So I don't know if it is a Jboss bug or a NET::SNMP perl-module bug.
            Do you thik I have to open a JIRA issue anyway?