Author: kkolinko
Date: Tue Apr 9 15:06:15 2013
New Revision: 1466068
URL: http://svn.apache.org/r1466068
Log:
CTR: docs
"Monitoring and Managing Tomcat"
Reduced indents and wrapped the text in several places. The document was
unreadable due to horizontal scrolling.
Modified:
tomcat/tc6.0.x/trunk/webapps/docs/monitoring.xml
Modified: tomcat/tc6.0.x/trunk/webapps/docs/monitoring.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/monitoring.xml?rev=1466068&r1=1466067&r2=1466068&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/monitoring.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/monitoring.xml Tue Apr 9 15:06:15 2013
@@ -106,103 +106,109 @@ controlRole tomcat
<p>To simplify JMX usage with Ant 1.6.x, a set of tasks is provided that may
be used with antlib.</p>
<p><b>antlib</b>: Copy your catalina-ant.jar from $CATALINA_HOME/lib to
$ANT_HOME/lib.</p>
- <p>The following example shows the JMX Accessor usage:</p>
+ <p>The following example shows the JMX Accessor usage:<br/>
+ <em>Note:</em> The <code>name</code> attribute value was wrapped here to be
+ more readable. It has to be all on the same line, without spaces.</p>
<table border="1">
- <tr><td><p><pre>
-<project name="Catalina Ant JMX"
- xmlns:jmx="antlib:org.apache.catalina.ant.jmx"
- default="state"
- basedir=".">
- <property name="jmx.server.name" value="localhost" />
- <property name="jmx.server.port" value="9012" />
- <property name="cluster.server.address" value="192.168.1.75" />
- <property name="cluster.server.port" value="9025" />
-
- <target name="state" description="Show JMX Cluster state">
- <jmx:open
- host="${jmx.server.name}"
- port="${jmx.server.port}"
- username="controlRole"
- password="tomcat"/>
- <jmx:get
-
name="Catalina:type=IDataSender,host=localhost,senderAddress=${cluster.server.address},senderPort=${cluster.server.port}"
- attribute="connected"
- resultproperty="IDataSender.backup.connected"
- echo="false"
- />
- <jmx:get
- name="Catalina:type=ClusterSender,host=localhost"
- attribute="senderObjectNames"
- resultproperty="senderObjectNames"
- echo="false"
- />
- <!-- get current maxActiveSession from ClusterTest application
- echo it to Ant output and store at
- property
<em>clustertest.maxActiveSessions.orginal</em>
- -->
- <jmx:get
- name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
- attribute="maxActiveSessions"
- resultproperty="clustertest.maxActiveSessions.orginal"
- echo="true"
- />
- <!-- set maxActiveSession to 100
- -->
- <jmx:set
- name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
- attribute="maxActiveSessions"
- value="100"
- type="int"
- />
- <!-- get all sessions and split result as delimiter
<em>SPACE</em> for easy
- access all session ids directly with Ant property sessions.[0..n].
- -->
- <jmx:invoke
- name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
- operation="listSessionIds"
- resultproperty="sessions"
- echo="false"
- delimiter=" "
- />
- <!-- Access session attribute <em>Hello</em> from first
session.
- -->
- <jmx:invoke
- name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
- operation="getSessionAttribute"
- resultproperty="Hello"
- echo="false"
- >
- <arg value="${sessions.0}"/>
- <arg value="Hello"/>
- </jmx:invoke>
- <!-- Query for all application manager.of the server from all hosts
- and bind all attributes from all found manager MBeans.
- -->
- <jmx:query
- name="Catalina:type=Manager,*"
- resultproperty="manager"
- echo="true"
- attributebinding="true"
- />
- <!-- echo the create properties -->
- <echo>
- senderObjectNames: ${senderObjectNames.0}
- IDataSender.backup.connected: ${IDataSender.backup.connected}
- session: ${sessions.0}
- manager.length: ${manager.length}
- manager.0.name: ${manager.0.name}
- manager.1.name: ${manager.1.name}
- hello: ${Hello}
- manager.ClusterTest.0.name: ${manager.ClusterTest.0.name}
- manager.ClusterTest.0.activeSessions:
${manager.ClusterTest.0.activeSessions}
- manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED:
${manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED}
- manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS:
${manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS}
- </echo>
+ <tr><td><pre>
+<project name="Catalina Ant JMX"
+ xmlns:jmx="antlib:org.apache.catalina.ant.jmx"
+ default="state"
+ basedir=".">
+ <property name="jmx.server.name" value="localhost" />
+ <property name="jmx.server.port" value="9012" />
+ <property name="cluster.server.address" value="192.168.1.75" />
+ <property name="cluster.server.port" value="9025" />
+
+ <target name="state" description="Show JMX Cluster state">
+ <jmx:open
+ host="${jmx.server.name}"
+ port="${jmx.server.port}"
+ username="controlRole"
+ password="tomcat"/>
+ <jmx:get
+ name=
+"Catalina:type=IDataSender,host=localhost,
+senderAddress=${cluster.server.address},senderPort=${cluster.server.port}"
+ attribute="connected"
+ resultproperty="IDataSender.backup.connected"
+ echo="false"
+ />
+ <jmx:get
+ name="Catalina:type=ClusterSender,host=localhost"
+ attribute="senderObjectNames"
+ resultproperty="senderObjectNames"
+ echo="false"
+ />
+ <!-- get current maxActiveSession from ClusterTest application
+ echo it to Ant output and store at
+ property <em>clustertest.maxActiveSessions.orginal</em>
+ -->
+ <jmx:get
+ name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
+ attribute="maxActiveSessions"
+ resultproperty="clustertest.maxActiveSessions.orginal"
+ echo="true"
+ />
+ <!-- set maxActiveSession to 100
+ -->
+ <jmx:set
+ name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
+ attribute="maxActiveSessions"
+ value="100"
+ type="int"
+ />
+ <!-- get all sessions and split result as delimiter
<em>SPACE</em> for easy
+ access all session ids directly with Ant property sessions.[0..n].
+ -->
+ <jmx:invoke
+ name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
+ operation="listSessionIds"
+ resultproperty="sessions"
+ echo="false"
+ delimiter=" "
+ />
+ <!-- Access session attribute <em>Hello</em> from first
session.
+ -->
+ <jmx:invoke
+ name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
+ operation="getSessionAttribute"
+ resultproperty="Hello"
+ echo="false"
+ >
+ <arg value="${sessions.0}"/>
+ <arg value="Hello"/>
+ </jmx:invoke>
+ <!-- Query for all application manager.of the server from all hosts
+ and bind all attributes from all found manager MBeans.
+ -->
+ <jmx:query
+ name="Catalina:type=Manager,*"
+ resultproperty="manager"
+ echo="true"
+ attributebinding="true"
+ />
+ <!-- echo the create properties -->
+<echo>
+senderObjectNames: ${senderObjectNames.0}
+IDataSender.backup.connected: ${IDataSender.backup.connected}
+session: ${sessions.0}
+manager.length: ${manager.length}
+manager.0.name: ${manager.0.name}
+manager.1.name: ${manager.1.name}
+hello: ${Hello}
+manager.ClusterTest.0.name: ${manager.ClusterTest.0.name}
+manager.ClusterTest.0.activeSessions: ${manager.ClusterTest.0.activeSessions}
+manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED:
+ ${manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED}
+manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS:
+ ${manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS}
+</echo>
+
+ </target>
- </target>
-
</project>
- </pre></p>
+</pre>
</td></tr>
</table>
<p><b>import:</b> Import the JMX Accessor Project with
@@ -295,22 +301,22 @@ List of Attributes<br/>
<p>
Example to open a new JMX connection<br/>
<source>
- <jmx:open
- host="${jmx.server.name}"
- port="${jmx.server.port}"
- />
+ <jmx:open
+ host="${jmx.server.name}"
+ port="${jmx.server.port}"
+ />
</source>
</p>
<p>
Example to open a JMX connection from URL, with authorization and
store at other reference <br/>
<source>
- <jmx:open
- url="service:jmx:rmi:///jndi/rmi://localhost:9024/jmxrmi"
- ref="jmx.server.9024"
- username="controlRole"
- password="tomcat"
- />
+ <jmx:open
+ url="service:jmx:rmi:///jndi/rmi://localhost:9024/jmxrmi"
+ ref="jmx.server.9024"
+ username="controlRole"
+ password="tomcat"
+ />
</source>
</p>
@@ -319,14 +325,14 @@ Example to open a JMX connection from UR
store at other reference, but only when property <em>jmx.if</em> exists and
<em>jmx.unless</em> not exists<br/>
<source>
- <jmx:open
- url="service:jmx:rmi:///jndi/rmi://localhost:9024/jmxrmi"
- ref="jmx.server.9024"
- username="controlRole"
- password="tomcat"
- if="jmx.if"
- unless="jmx.unless"
- />
+ <jmx:open
+ url="service:jmx:rmi:///jndi/rmi://localhost:9024/jmxrmi"
+ ref="jmx.server.9024"
+ username="controlRole"
+ password="tomcat"
+ if="jmx.if"
+ unless="jmx.unless"
+ />
</source>
</p>
<p><b>Note</b>: All properties from <em>jmxOpen</em> task also exists at all
@@ -405,44 +411,49 @@ List of Attributes<br/>
<p>
Example to get remote MBean attribute from default JMX connection <br/>
<source>
- <jmx:get
- name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
- attribute="maxActiveSessions"
- resultproperty="servlets-examples.maxActiveSessions"
- />
+ <jmx:get
+ name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
+ attribute="maxActiveSessions"
+ resultproperty="servlets-examples.maxActiveSessions"
+ />
</source>
</p>
<p>
Example to get and result array and split it at separate properties<br/>
<source>
- <jmx:get
- name="Catalina:type=ClusterSender,host=localhost"
- attribute="senderObjectNames"
- resultproperty="senderObjectNames"
- />
+ <jmx:get
+ name="Catalina:type=ClusterSender,host=localhost"
+ attribute="senderObjectNames"
+ resultproperty="senderObjectNames"
+ />
</source>
Access the senderObjectNames properties with:
<source>
- ${senderObjectNames.length} give the number of returned sender list.
- ${senderObjectNames.[0..N]} found all sender object names
+ ${senderObjectNames.length} give the number of returned sender list.
+ ${senderObjectNames.[0..N]} found all sender object names
</source>
</p>
<p>
-Example to get IDataSender attribute connected only when cluster is configured.
+Example to get IDataSender attribute connected only when cluster is
configured.<br/>
+<em>Note:</em> The <code>name</code> attribute value was wrapped here to be
+more readable. It has to be all on the same line, without spaces.
+</p>
<source>
-<jmx:query
+ <jmx:query
failonerror="false"
name="Catalina:type=Cluster,host=${tomcat.application.host}"
resultproperty="cluster"
-/>
-<jmx:get
-
name="Catalina:type=IDataSender,host=${tomcat.application.host},senderAddress=${cluster.backup.address},senderPort=${cluster.backup.port}"
+ />
+ <jmx:get
+ name=
+"Catalina:type=IDataSender,host=${tomcat.application.host},
+senderAddress=${cluster.backup.address},senderPort=${cluster.backup.port}"
attribute="connected"
resultproperty="datasender.connected"
if="cluster.0.name" />
</source>
-</p>
+
</section>
@@ -507,12 +518,12 @@ List of Attributes<br/>
<p>
Example to set remote MBean attribute value<br/>
<source>
- <jmx:set
- name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
- attribute="maxActiveSessions"
- value="500"
- type="int"
- />
+ <jmx:set
+ name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
+ attribute="maxActiveSessions"
+ value="500"
+ type="int"
+ />
</source>
</p>
@@ -589,9 +600,9 @@ List of Attributes<br/>
<p>
stop an application <br/>
<source>
- <jmx:invoke
- name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
- operation="stop"/>
+ <jmx:invoke
+ name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
+ operation="stop"/>
</source>
Now you can find the sessionid at <em>${sessions.[0..N}</em> properties and
access the count
with ${sessions.length} property.
@@ -599,12 +610,12 @@ with ${sessions.length} property.
<p>
Example to get all sessionids <br/>
<source>
- <jmx:invoke
- name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
- operation="listSessionIds"
- resultproperty="sessions"
- delimiter=" "
- />
+ <jmx:invoke
+ name="Catalina:type=Manager,path=/servlets-examples,host=localhost"
+ operation="listSessionIds"
+ resultproperty="sessions"
+ delimiter=" "
+ />
</source>
Now you can find the sessionid at <em>${sessions.[0..N}</em> properties and
access the count
with ${sessions.length} property.
@@ -612,20 +623,20 @@ with ${sessions.length} property.
<p>
Example to get remote MBean session attribute from session ${sessionid.0}<br/>
<source>
- <jmx:invoke
- name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
- operation="getSessionAttribute"
- resultproperty="hello">
- <arg value="${sessionid.0}"/>
- <arg value="Hello" />
- </jmx:invoke>
+ <jmx:invoke
+ name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
+ operation="getSessionAttribute"
+ resultproperty="hello">
+ <arg value="${sessionid.0}"/>
+ <arg value="Hello" />
+ </jmx:invoke>
</source>
</p>
<p>
Example to create a new access logger valve at vhost <em>localhost</em>
<source>
<jmx:invoke
- name="Catalina:type=MBeanFactory"
+ name="Catalina:type=MBeanFactory"
operation="createAccessLoggerValve"
resultproperty="accessLoggerObjectName"
>
@@ -709,8 +720,8 @@ List of Attributes<br/>
Get all Manager ObjectNames from all services and Hosts <br/>
<source>
<jmx:query
- name="Catalina:type=Manager,*
- resultproperty="manager" />
+ name="Catalina:type=Manager,*
+ resultproperty="manager" />
</source>
Now you can find the Session Manager at <em>${manager.[0..N].name}</em>
properties and access the result object counter with ${manager.length}
property.
@@ -719,9 +730,9 @@ properties and access the result object
Example to get the Manager from <em>servlet-examples</em> application an bind
all MBean properties<br/>
<source>
<jmx:query
- name="Catalina:type=Manager,path=/servlet-examples,host=localhost*"
- attributebinding="true"
- resultproperty="manager.servletExamples" />
+ name="Catalina:type=Manager,path=/servlet-examples,host=localhost*"
+ attributebinding="true"
+ resultproperty="manager.servletExamples" />
</source>
Now you can find the manager at <em>${manager.servletExamples.0.name}</em>
property
and can access all properties from this manager with
<em>${manager.servletExamples.0.[manager attribute names]</em>}.
@@ -731,7 +742,7 @@ The result object counter from MBeans is
<p>
Example to get all MBeans from a server and store inside an external XML
property file<br/>
<source>
-<project name="jmx.query"
+<project name="jmx.query"
xmlns:jmx="antlib:org.apache.catalina.ant.jmx"
default="query-all" basedir=".">
<property name="jmx.host" value="localhost"/>
@@ -740,27 +751,27 @@ Example to get all MBeans from a server
<property name="jmx.password" value="tomcat"/>
<target name="query-all" description="Query all MBeans of a server">
-<!-- Configure connection -->
-<jmx:open
+ <!-- Configure connection -->
+ <jmx:open
host="${jmx.host}"
port="${jmx.port}"
ref="jmx.server"
username="${jmx.username}"
password="${jmx.password}"/>
-<!-- Query MBean list -->
-<jmx:query
+ <!-- Query MBean list -->
+ <jmx:query
name="*:*"
resultproperty="mbeans"
attributebinding="false"/>
-
-<echoproperties
+
+ <echoproperties
destfile="mbeans.properties"
prefix="mbeans."
format="xml"/>
-
-<!-- Print results -->
-<echo
- message="Number of MBeans in server ${jmx.host}:${jmx.port} is
${mbeans.length}"/>
+
+ <!-- Print results -->
+ <echo message=
+ "Number of MBeans in server ${jmx.host}:${jmx.port} is
${mbeans.length}"/>
</target>
</project>
</source>
@@ -825,13 +836,13 @@ List of Attributes<br/>
<p>
Example to create remote MBean<br/>
<source>
- <jmx:create
- ref="${jmx.reference}"
- name="Catalina:type=MBeanFactory"
- className="org.apache.commons.modeler.BaseModelMBean"
- classLoader="Catalina:type=ServerClassLoader,name=server">
- <Arg value="org.apache.catalina.mbeans.MBeanFactory" />
- </jmx:create>
+ <jmx:create
+ ref="${jmx.reference}"
+ name="Catalina:type=MBeanFactory"
+ className="org.apache.commons.modeler.BaseModelMBean"
+ classLoader="Catalina:type=ServerClassLoader,name=server">
+ <arg value="org.apache.catalina.mbeans.MBeanFactory" />
+ </jmx:create>
</source>
</p>
<p>
@@ -883,9 +894,9 @@ List of Attributes<br/>
<p>
Example to unregister remote MBean<br/>
<source>
- <jmx:unregister
- name="Catalina:type=MBeanFactory"
- />
+ <jmx:unregister
+ name="Catalina:type=MBeanFactory"
+ />
</source>
</p>
<p>
@@ -1015,26 +1026,27 @@ List of Attributes<br/>
<p>
Wait for server connection and that cluster backup node is accessable<br/>
<source>
- <target name="wait">
- <waitfor maxwait="${maxwait}" maxwaitunit="second"
timeoutproperty="server.timeout" >
- <and>
- <socket server="${server.name}" port="${server.port}"/>
- <http url="${url}"/>
- <jmx:condition
- operation="=="
- host="localhost"
- port="9014"
- username="controlRole"
- password="tomcat"
-
name="Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
- attribute="connected"
- value="true"
- />
- </and>
- </waitfor>
- <fail if="server.timeout" message="Server ${url} don't answer
inside ${maxwait} sec" />
- <echo message="Server ${url} alive" />
- </target>
+<target name="wait">
+ <waitfor maxwait="${maxwait}" maxwaitunit="second"
timeoutproperty="server.timeout" >
+ <and>
+ <socket server="${server.name}" port="${server.port}"/>
+ <http url="${url}"/>
+ <jmx:condition
+ operation="=="
+ host="localhost"
+ port="9014"
+ username="controlRole"
+ password="tomcat"
+ name=
+"Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
+ attribute="connected"
+ value="true"
+ />
+ </and>
+ </waitfor>
+ <fail if="server.timeout" message="Server ${url} don't answer inside
${maxwait} sec" />
+ <echo message="Server ${url} alive" />
+</target>
</source>
</p>
@@ -1117,25 +1129,26 @@ List of Attributes<br/>
<p>
Wait for server connection and that cluster backup node is accessible<br/>
<source>
- <target name="wait">
- <waitfor maxwait="${maxwait}" maxwaitunit="second"
timeoutproperty="server.timeout" >
- <and>
- <socket server="${server.name}" port="${server.port}"/>
- <http url="${url}"/>
- <jmx:equals
- host="localhost"
- port="9014"
- username="controlRole"
- password="tomcat"
-
name="Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
- attribute="connected"
- value="true"
- />
- </and>
- </waitfor>
- <fail if="server.timeout" message="Server ${url} don't answer
inside ${maxwait} sec" />
- <echo message="Server ${url} alive" />
- </target>
+<target name="wait">
+ <waitfor maxwait="${maxwait}" maxwaitunit="second"
timeoutproperty="server.timeout" >
+ <and>
+ <socket server="${server.name}" port="${server.port}"/>
+ <http url="${url}"/>
+ <jmx:equals
+ host="localhost"
+ port="9014"
+ username="controlRole"
+ password="tomcat"
+ name=
+"Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
+ attribute="connected"
+ value="true"
+ />
+ </and>
+ </waitfor>
+ <fail if="server.timeout" message="Server ${url} don't answer inside
${maxwait} sec" />
+ <echo message="Server ${url} alive" />
+</target>
</source>
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]