JMXAccessorQueryTask: query MBean Ant task

List of Attributes

Attribute Description Default value
name JMX ObjectName query string — Catalina:type=Manager,*
ref JMX Connection reference jmx.server
echo Echo command usage (access and result) false
resultproperty Prefix project property name to all founded MBeans (mbeans.[0..N].objectname)
attributebinduing bind ALL MBean attributes in addition to name false
delimiter Split result with delimiter (java.util.StringTokenizier) and use resultproperty as prefix to store tokens.
separatearrayresults When return value is an array, save result as property list ($resultproperty.[0..N] and $resultproperty.length) true

Get all Manager ObjectNames from all services and Hosts

<jmx:query

name=”Catalina:type=Manager,*

resultproperty=”manager” />

 

Now you can find the Session Manager at ${manager.[0..N].name} properties and access the result object counter with ${manager.length} property.

 

Example to get the Manager from servlet-examples application an bind all MBean properties

 

<jmx:query

name=”Catalina:type=Manager,context=/servlet-examples,host=localhost*”

attributebinding=”true”

resultproperty=”manager.servletExamples” />

 

Now you can find the manager at ${manager.servletExamples.0.name} property and can access all properties from this manager with ${manager.servletExamples.0.[manager attribute names]}. The result object counter from MBeans is stored ad ${manager.length} property.

Example to get all MBeans from a server and store inside an external XML property file

 

<project name=”jmx.query”

xmlns:jmx=”antlib:org.apache.catalina.ant.jmx”

default=”query-all” basedir=”.”>

<property name=”jmx.host” value=”localhost”/>

<property name=”jmx.port” value=”8050″/>

<property name=”jmx.username” value=”controlRole”/>

<property name=”jmx.password” value=”tomcat”/>

 

<target name=”query-all” description=”Query all MBeans of a server”>

<!– Configure connection –>

<jmx:open

host=”${jmx.host}”

port=”${jmx.port}”

ref=”jmx.server”

username=”${jmx.username}”

password=”${jmx.password}”/>

 

<!– Query MBean list –>

<jmx:query

name=”*:*”

resultproperty=”mbeans”

attributebinding=”false”/>

 

<echoproperties

destfile=”mbeans.properties”

prefix=”mbeans.”

format=”xml”/>

 

<!– Print results –>

<echo message=

“Number of MBeans in server ${jmx.host}:${jmx.port} is ${mbeans.length}”/>

</target>

</project>

Now you can find all MBeans inside the file mbeans.properties.

Share this post
[social_warfare]
Setting Up the Cache
The Per-View Cache

Get industry recognized certification – Contact us

keyboard_arrow_up