JBossSNMPAdapterGetValues

简介:
 

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,如需转载请自行联系原作者
目录
相关文章
|
XML Java 数据格式
常用的xpath
常用的xpath
108 0
|
3月前
|
SQL Java 数据库
什么是 PagingAndSortingRepository?
【8月更文挑战第21天】
74 0
|
5月前
PAT 1001 和 1002 A+B问题
PAT 1001 和 1002 A+B问题
|
6月前
|
SQL 分布式计算 数据库
ApacheHudi使用问题汇总(二)
ApacheHudi使用问题汇总(二)
112 0
|
开发框架 移动开发 安全
mPaaS
mPaaS是阿里云提供的一款移动应用开发平台,支持开发iOS和Android平台的原生应用程序和H5应用程序。mPaaS提供了丰富的移动应用开发服务和工具,包括移动应用开发框架、云端API、移动支付、推送服务、移动安全等,可以帮助开发者快速构建高质量的移动应用程序。
807 0
|
XML 数据格式
一起来了解XPath吧!
一起来了解XPath吧!
113 0
Pangram
Pangram
126 0
Pangram
PAT有几个pat
字符串APPAPT中包含了两个单词“PAT”,其中第一个PAT是第2位§,第4位(A),第6位(T);第二个PAT是第3位§,第4位(A),第6位(T)。 现给定字符串,问一共可以形成多少个PAT?
130 0
|
JavaScript 前端开发