JBossSNMPAdapterGetValues

本文介绍如何使用JBoss SNMP适配器映射SNMP OID到MBeans及其属性,并展示了如何配置请求处理器来读取映射文件。此外,还提供了示例MIB文件和如何设置可写属性的方法。
 

Mapping-configuration, attributes.xml

This file defines the mapping from SNMP-oids to MBeans and their attributes.
(Note: xml driven get/set mapping functionality is available since  jboss v4.0.4.GA.)
The toplevel element  attribute-mapping contains a list of mbeans.
Each  mbean element has to have a  name attribute that specifies the
JMX object name of the mbean to monitor. It can also have an  oid-prefix element
that will be prepended to the oids of the attributes. The  mbean element contains a list
of  attribute tags that each have to have a  name attribute for the
MBean-attribute-name and an  oid attribute that defines the oid under which
this attribute can be queried.

Setup in general configuration

In order to work, the mapping file must be included in the SnmpAgentService-MBean in an attribute called  RequestHandlerResName as the following snippet shows

  <!-- The SNMP adaptor MBean -->
  <mbean code="org.jboss.jmx.adaptor.snmp.agent.SnmpAgentService"
         name="jboss.jmx:name=SnmpAgent,service=snmp,type=adaptor">
    
    <attribute name="RequestHandlerClassName">org.jboss.jmx.adaptor.snmp.agent.RequestHandlerImpl</attribute>       
    <attribute name="RequestHandlerResName">/attributes.xml</attribute>

Example

This is an excerpt from the sample file from the snmp-adaptor:

<attribute-mappings>
     <!-- system basic information -->
     <mbean name="jboss.system:type=ServerInfo" oid-prefix=".1.2.3.4.1">
          <attribute name="ActiveThreadCount" oid=".1"></attribute>
          <attribute name="FreeMemory" oid=".2"></attribute>
          <attribute name="MaxMemory" oid=".3"></attribute>
     </mbean>
     <mbean name="jboss.system:service=ThreadPool">
          <attribute name="QueueSize" oid=".1.2.3.4.1.4"></attribute>
     </mbean>
     <!-- tomcat global http request processing -->
     <mbean name="jboss.web:name=http-0.0.0.0-8080,type=GlobalRequestProcessor">
          <attribute name="requestCount" oid=".1.2.3.4.1.5"></attribute>
     </mbean>
     <!-- Tx Manager statistics -->
     <mbean name="jboss:service=TransactionManager">
          <attribute name="CommitCount" oid=".1.2.3.4.1.6"></attribute>
          <attribute name="RollbackCount" oid=".1.2.3.4.1.7"></attribute>
          <attribute name="TransactionCount" oid=".1.2.3.4.1.8"></attribute>
     </mbean>
     <!-- DefaultDS statistics -->
     <mbean name="jboss.jca:name=DefaultDS,service=ManagedConnectionPool" 
          oid-prefix=".1.2.3.4.1">
          <attribute name="InUseConnectionCount" oid=".9"></attribute>
     </mbean>
</attribute-mappings>
Note that the provided values will change in the future.
The adaptor now also has support for the MIB-2 system group ( RFC1213)

Reload a changed config

The SnmpAdaptor-MBean now has a  reconfigureRequestHandler Method which forces the adaptor to reread the attributes.xml file without the need to completely restart the adaptor.

Example SNMP-MIB for the above example file

This is an extremely simple MIB file that you can load into your management station to
query the respective values.
Note that this MIB will change in the future.

JBOSS-MIB DEFINITIONS ::=BEGIN
-- Tree roots
org     OBJECT IDENTIFIER ::= { iso 2 } -- "iso" = 1
jboss     OBJECT IDENTIFIER ::= { org 3 }
as     OBJECT IDENTIFIER ::= { jboss 4 }
system     OBJECT IDENTIFIER ::= { as 1 }  -- .1.2.3.4.1
mgmt      OBJECT IDENTIFIER ::= { as 5 }
snmp     OBJECT IDENTIFIER ::= { mgmt 6 }
agent      OBJECT IDENTIFIER ::= { snmp 7 }
-- system parameters
activeThreadCount OBJECT-TYPE
     ACCESS read-only 
     DESCRIPTION
          "The number of active Threads in the system"
     ::= { system 1 } -- .1.2.3.4.1.1
freeMemory OBJECT IDENTIFIER ::= {system 2} -- .1.2.3.4.1.2
maxMemory OBJECT IDENTIFIER ::= {system 3} -- .1.2.3.4.1.3
threadPoolQueueSize OBJECT-TYPE
     ACCESS read-only
     DESCRIPTION
          "The size of the thread pool queue"
     ::= {system 4 }
requestCount8080 OBJECT IDENTIFIER ::= {system 5}
txCommitCount OBJECT IDENTIFIER ::= {system 6 }
txRollbackCount OBJECT IDENTIFIER ::= {system 7 }
txActiveCount OBJECT IDENTIFIER ::= {system 8 }
dbInUseCount OBJECT-TYPE
     ACCES read-only
     DESCRIPTION
          "The number of db connections currently in use"
     ::= { system 9 }

snmp-set

The adaptor now also supports snmp-set. In order for an entry to be settable, it not only needs to be marked read-write in the MIB, but also have an attribute  mode in the attributes.xml file with a value of  rw as in the following example:

   <mbean name="jboss.jmx:name=SnmpAgent,service=snmp,type=systemInfo" 
      oid-prefix=".1.3.6.1.2.1.1">
      <attribute name="SysDescr" oid=".1" mode="rw"></attribute> <!-- can be modified over snmp -->
Note that for this to work, you have to define a write-community in jboss-service.xml for the
main adaptor mbean and also have to set it in your agent. If you fail to do so, the set-request will silently time out (this comes from the underlying library).










本文转自 jxwpx 51CTO博客,原文链接:http://blog.51cto.com/jxwpx/214071,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值