Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 771 | blopes | 1 | <!DOCTYPE html SYSTEM "about:legacy-compat"> |
| 2 | <html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><link href="./images/docs-stylesheet.css" rel="stylesheet" type="text/css"><title>Apache Tomcat 9 (9.0.112) - Monitoring and Managing Tomcat</title></head><body><div id="wrapper"><header><div id="header"><div><div><div class="logo noPrint"><a href="https://tomcat.apache.org/"><img alt="Tomcat Home" src="./images/tomcat.png"></a></div><div style="height: 1px;"></div><div class="asfLogo noPrint"><a href="https://www.apache.org/" target="_blank"><img src="./images/asf-logo.svg" alt="The Apache Software Foundation" style="width: 266px; height: 83px;"></a></div><h1>Apache Tomcat 9</h1><div class="versionInfo"> |
||
| 3 | Version 9.0.112, |
||
| 4 | <time datetime="2025-11-06">Nov 6 2025</time></div><div style="height: 1px;"></div><div style="clear: left;"></div></div></div></div></header><div id="middle"><div><div id="mainLeft" class="noprint"><div><nav><div><h2>Links</h2><ul><li><a href="index.html">Docs Home</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/FAQ">FAQ</a></li></ul></div><div><h2>User Guide</h2><ul><li><a href="introduction.html">1) Introduction</a></li><li><a href="setup.html">2) Setup</a></li><li><a href="appdev/index.html">3) First webapp</a></li><li><a href="deployer-howto.html">4) Deployer</a></li><li><a href="manager-howto.html">5) Manager</a></li><li><a href="host-manager-howto.html">6) Host Manager</a></li><li><a href="realm-howto.html">7) Realms and AAA</a></li><li><a href="security-manager-howto.html">8) Security Manager</a></li><li><a href="jndi-resources-howto.html">9) JNDI Resources</a></li><li><a href="jndi-datasource-examples-howto.html">10) JDBC DataSources</a></li><li><a href="class-loader-howto.html">11) Classloading</a></li><li><a href="jasper-howto.html">12) JSPs</a></li><li><a href="ssl-howto.html">13) SSL/TLS</a></li><li><a href="ssi-howto.html">14) SSI</a></li><li><a href="cgi-howto.html">15) CGI</a></li><li><a href="proxy-howto.html">16) Proxy Support</a></li><li><a href="mbeans-descriptors-howto.html">17) MBeans Descriptors</a></li><li><a href="default-servlet.html">18) Default Servlet</a></li><li><a href="cluster-howto.html">19) Clustering</a></li><li><a href="balancer-howto.html">20) Load Balancer</a></li><li><a href="connectors.html">21) Connectors</a></li><li><a href="monitoring.html">22) Monitoring and Management</a></li><li><a href="logging.html">23) Logging</a></li><li><a href="apr.html">24) APR/Native</a></li><li><a href="virtual-hosting-howto.html">25) Virtual Hosting</a></li><li><a href="aio.html">26) Advanced IO</a></li><li><a href="maven-jars.html">27) Mavenized</a></li><li><a href="security-howto.html">28) Security Considerations</a></li><li><a href="windows-service-howto.html">29) Windows Service</a></li><li><a href="windows-auth-howto.html">30) Windows Authentication</a></li><li><a href="jdbc-pool.html">31) Tomcat's JDBC Pool</a></li><li><a href="web-socket-howto.html">32) WebSocket</a></li><li><a href="rewrite.html">33) Rewrite</a></li><li><a href="cdi.html">34) CDI 2 and JAX-RS</a></li><li><a href="graal.html">35) AOT/GraalVM Support</a></li></ul></div><div><h2>Reference</h2><ul><li><a href="RELEASE-NOTES.txt">Release Notes</a></li><li><a href="config/index.html">Configuration</a></li><li><a href="api/index.html">Tomcat Javadocs</a></li><li><a href="servletapi/index.html">Servlet 4.0 Javadocs</a></li><li><a href="jspapi/index.html">JSP 2.3 Javadocs</a></li><li><a href="elapi/index.html">EL 3.0 Javadocs</a></li><li><a href="websocketapi/index.html">WebSocket 1.1 Javadocs</a></li><li><a href="jaspicapi/index.html">JASPIC 1.1 Javadocs</a></li><li><a href="annotationapi/index.html">Common Annotations 1.3 Javadocs</a></li><li><a href="https://tomcat.apache.org/connectors-doc/">JK 1.2 Documentation</a></li></ul></div><div><h2>Apache Tomcat Development</h2><ul><li><a href="building.html">Building</a></li><li><a href="changelog.html">Changelog</a></li><li><a href="https://cwiki.apache.org/confluence/display/TOMCAT/Tomcat+Versions">Status</a></li><li><a href="developers.html">Developers</a></li><li><a href="architecture/index.html">Architecture</a></li><li><a href="tribes/introduction.html">Tribes</a></li></ul></div></nav></div></div><div id="mainRight"><div id="content"><h2>Monitoring and Managing Tomcat</h2><h3 id="Table_of_Contents">Table of Contents</h3><div class="text"> |
||
| 5 | <ul><li><a href="#Introduction">Introduction</a></li><li><a href="#Enabling_JMX_Remote">Enabling JMX Remote</a></li><li><a href="#Manage_Tomcat_with_JMX_remote_Ant_Tasks">Manage Tomcat with JMX remote Ant Tasks</a></li><li><a href="#JMXAccessorOpenTask_-_JMX_open_connection_task">JMXAccessorOpenTask - JMX open connection task</a></li><li><a href="#JMXAccessorGetTask:__get_attribute_value_Ant_task">JMXAccessorGetTask: get attribute value Ant task</a></li><li><a href="#JMXAccessorSetTask:__set_attribute_value_Ant_task">JMXAccessorSetTask: set attribute value Ant task</a></li><li><a href="#JMXAccessorInvokeTask:__invoke_MBean_operation_Ant_task">JMXAccessorInvokeTask: invoke MBean operation Ant task</a></li><li><a href="#JMXAccessorQueryTask:__query_MBean_Ant_task">JMXAccessorQueryTask: query MBean Ant task</a></li><li><a href="#JMXAccessorCreateTask:__remote_create_MBean_Ant_task">JMXAccessorCreateTask: remote create MBean Ant task</a></li><li><a href="#JMXAccessorUnregisterTask:__remote_unregister_MBean_Ant_task">JMXAccessorUnregisterTask: remote unregister MBean Ant task</a></li><li><a href="#JMXAccessorCondition:__express_condition">JMXAccessorCondition: express condition</a></li><li><a href="#JMXAccessorEqualsCondition:__equals_MBean_Ant_condition">JMXAccessorEqualsCondition: equals MBean Ant condition</a></li><li><a href="#Using_the_JMXProxyServlet">Using the JMXProxyServlet</a></li></ul> |
||
| 6 | </div><h3 id="Introduction">Introduction</h3><div class="text"> |
||
| 7 | |||
| 8 | <p>Monitoring is a key aspect of system administration. Looking inside a |
||
| 9 | running server, obtaining some statistics or reconfiguring some aspects of |
||
| 10 | an application are all daily administration tasks.</p> |
||
| 11 | |||
| 12 | </div><h3 id="Enabling_JMX_Remote">Enabling JMX Remote</h3><div class="text"> |
||
| 13 | |||
| 14 | <p><strong>Note:</strong> This configuration is needed only if you are |
||
| 15 | going to monitor Tomcat remotely. It is not needed if you are going |
||
| 16 | to monitor it locally, using the same user that Tomcat runs with.</p> |
||
| 17 | |||
| 18 | <p>The Oracle website includes the list of options and how to configure |
||
| 19 | JMX Remote on Java 8: |
||
| 20 | <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html"> |
||
| 21 | http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html</a>. |
||
| 22 | </p> |
||
| 23 | <p>The following is a quick configuration guide for Java 8:</p> |
||
| 24 | <p>Add the following parameters to <code>setenv.bat</code> script of your |
||
| 25 | Tomcat (see <a href="RUNNING.txt">RUNNING.txt</a> for details).<br> |
||
| 26 | <em>Note:</em> This syntax is for Microsoft Windows. The command has |
||
| 27 | to be on the same line. It is wrapped to be more readable. If Tomcat is |
||
| 28 | running as a Windows service, use its configuration dialog to set |
||
| 29 | java options for the service. |
||
| 30 | For Linux, MacOS, etc, remove <code>"set "</code> from beginning of the |
||
| 31 | line. |
||
| 32 | </p> |
||
| 33 | <div class="codeBox"><pre><code>set CATALINA_OPTS=-Dcom.sun.management.jmxremote.port=%my.jmx.port% |
||
| 34 | -Dcom.sun.management.jmxremote.rmi.port=%my.rmi.port% |
||
| 35 | -Dcom.sun.management.jmxremote.ssl=false |
||
| 36 | -Dcom.sun.management.jmxremote.authenticate=false</code></pre></div> |
||
| 37 | <p>If you don't set <code>com.sun.management.jmxremote.rmi.port</code> then the |
||
| 38 | JSR 160 JMX-Adaptor will select a port at random which will may it difficult to |
||
| 39 | configure a firewall to allow access.</p> |
||
| 40 | |||
| 41 | <p>If you require TLS:</p> |
||
| 42 | <ol> |
||
| 43 | <li>change and add this: |
||
| 44 | <div class="codeBox"><pre><code> -Dcom.sun.management.jmxremote.ssl=true |
||
| 45 | -Dcom.sun.management.jmxremote.registry.ssl=true |
||
| 46 | </code></pre></div></li> |
||
| 47 | <li>to configure the protocols and/or cipher suites use: |
||
| 48 | <div class="codeBox"><pre><code> -Dcom.sun.management.jmxremote.ssl.enabled.protocols=%my.jmx.ssl.protocols% |
||
| 49 | -Dcom.sun.management.jmxremote.ssl.enabled.cipher.suites=%my.jmx.cipher.suites% |
||
| 50 | </code></pre></div></li> |
||
| 51 | <li>to client certificate authentication use: |
||
| 52 | <div class="codeBox"><pre><code> -Dcom.sun.management.jmxremote.ssl.need.client.auth=%my.jmx.ssl.clientauth%</code></pre></div></li> |
||
| 53 | </ol> |
||
| 54 | <p>If you require authorization (it is strongly recommended that TLS is always |
||
| 55 | used with authentication):</p> |
||
| 56 | <ol> |
||
| 57 | <li>change and add this: |
||
| 58 | <div class="codeBox"><pre><code> -Dcom.sun.management.jmxremote.authenticate=true |
||
| 59 | -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password |
||
| 60 | -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access</code></pre></div> |
||
| 61 | </li> |
||
| 62 | <li>edit the access authorization file <em>$CATALINA_BASE/conf/jmxremote.access</em>: |
||
| 63 | <div class="codeBox"><pre><code>monitorRole readonly |
||
| 64 | controlRole readwrite</code></pre></div> |
||
| 65 | </li> |
||
| 66 | <li>edit the password file <em>$CATALINA_BASE/conf/jmxremote.password</em>: |
||
| 67 | <div class="codeBox"><pre><code>monitorRole tomcat |
||
| 68 | controlRole tomcat</code></pre></div> |
||
| 69 | <b>Tip</b>: The password file should be read-only and only accessible by the |
||
| 70 | operating system user Tomcat is running as. |
||
| 71 | </li> |
||
| 72 | <li>Alternatively, you can configure a JAAS login module with: |
||
| 73 | <div class="codeBox"><pre><code> -Dcom.sun.management.jmxremote.login.config=%login.module.name%</code></pre></div></li> |
||
| 74 | </ol> |
||
| 75 | |||
| 76 | <p>If you need to specify a host name to be used in the RMI stubs sent to the |
||
| 77 | client (e.g. because the public host name that must be used to connect is not |
||
| 78 | the same as the local host name) then you can set:</p> |
||
| 79 | <div class="codeBox"><pre><code>set CATALINA_OPTS=-Djava.rmi.server.hostname</code></pre></div> |
||
| 80 | |||
| 81 | <p>If you need to specify a specific interface for the JMX service to bind to |
||
| 82 | then you can set:</p> |
||
| 83 | <div class="codeBox"><pre><code>set CATALINA_OPTS=-Dcom.sun.management.jmxremote.host</code></pre></div> |
||
| 84 | |||
| 85 | </div><h3 id="Manage_Tomcat_with_JMX_remote_Ant_Tasks">Manage Tomcat with JMX remote Ant Tasks</h3><div class="text"> |
||
| 86 | <p>To simplify JMX usage with Ant, a set of tasks is provided that may |
||
| 87 | be used with antlib.</p> |
||
| 88 | <p><b>antlib</b>: Copy your catalina-ant.jar from $CATALINA_HOME/lib to $ANT_HOME/lib.</p> |
||
| 89 | <p>The following example shows the JMX Accessor usage:<br> |
||
| 90 | <em>Note:</em> The <code>name</code> attribute value was wrapped here to be |
||
| 91 | more readable. It has to be all on the same line, without spaces.</p> |
||
| 92 | <div class="codeBox"><pre><code><project name="Catalina Ant JMX" |
||
| 93 | xmlns:jmx="antlib:org.apache.catalina.ant.jmx" |
||
| 94 | default="state" |
||
| 95 | basedir="."> |
||
| 96 | <property name="jmx.server.name" value="localhost" /> |
||
| 97 | <property name="jmx.server.port" value="9012" /> |
||
| 98 | <property name="cluster.server.address" value="192.168.1.75" /> |
||
| 99 | <property name="cluster.server.port" value="9025" /> |
||
| 100 | |||
| 101 | <target name="state" description="Show JMX Cluster state"> |
||
| 102 | <jmx:open |
||
| 103 | host="${jmx.server.name}" |
||
| 104 | port="${jmx.server.port}" |
||
| 105 | username="controlRole" |
||
| 106 | password="tomcat"/> |
||
| 107 | <jmx:get |
||
| 108 | name= |
||
| 109 | "Catalina:type=IDataSender,host=localhost, |
||
| 110 | senderAddress=${cluster.server.address},senderPort=${cluster.server.port}" |
||
| 111 | attribute="connected" |
||
| 112 | resultproperty="IDataSender.backup.connected" |
||
| 113 | echo="false" |
||
| 114 | /> |
||
| 115 | <jmx:get |
||
| 116 | name="Catalina:type=ClusterSender,host=localhost" |
||
| 117 | attribute="senderObjectNames" |
||
| 118 | resultproperty="senderObjectNames" |
||
| 119 | echo="false" |
||
| 120 | /> |
||
| 121 | <!-- get current maxActiveSession from ClusterTest application |
||
| 122 | echo it to Ant output and store at |
||
| 123 | property <em>clustertest.maxActiveSessions.original</em> |
||
| 124 | --> |
||
| 125 | <jmx:get |
||
| 126 | name="Catalina:type=Manager,context=/ClusterTest,host=localhost" |
||
| 127 | attribute="maxActiveSessions" |
||
| 128 | resultproperty="clustertest.maxActiveSessions.original" |
||
| 129 | echo="true" |
||
| 130 | /> |
||
| 131 | <!-- set maxActiveSession to 100 |
||
| 132 | --> |
||
| 133 | <jmx:set |
||
| 134 | name="Catalina:type=Manager,context=/ClusterTest,host=localhost" |
||
| 135 | attribute="maxActiveSessions" |
||
| 136 | value="100" |
||
| 137 | type="int" |
||
| 138 | /> |
||
| 139 | <!-- get all sessions and split result as delimiter <em>SPACE</em> for easy |
||
| 140 | access all session ids directly with Ant property sessions.[0..n]. |
||
| 141 | --> |
||
| 142 | <jmx:invoke |
||
| 143 | name="Catalina:type=Manager,context=/ClusterTest,host=localhost" |
||
| 144 | operation="listSessionIds" |
||
| 145 | resultproperty="sessions" |
||
| 146 | echo="false" |
||
| 147 | delimiter=" " |
||
| 148 | /> |
||
| 149 | <!-- Access session attribute <em>Hello</em> from first session. |
||
| 150 | --> |
||
| 151 | <jmx:invoke |
||
| 152 | name="Catalina:type=Manager,context=/ClusterTest,host=localhost" |
||
| 153 | operation="getSessionAttribute" |
||
| 154 | resultproperty="Hello" |
||
| 155 | echo="false" |
||
| 156 | > |
||
| 157 | <arg value="${sessions.0}"/> |
||
| 158 | <arg value="Hello"/> |
||
| 159 | </jmx:invoke> |
||
| 160 | <!-- Query for all application manager.of the server from all hosts |
||
| 161 | and bind all attributes from all found manager MBeans. |
||
| 162 | --> |
||
| 163 | <jmx:query |
||
| 164 | name="Catalina:type=Manager,*" |
||
| 165 | resultproperty="manager" |
||
| 166 | echo="true" |
||
| 167 | attributebinding="true" |
||
| 168 | /> |
||
| 169 | <!-- echo the create properties --> |
||
| 170 | <echo> |
||
| 171 | senderObjectNames: ${senderObjectNames.0} |
||
| 172 | IDataSender.backup.connected: ${IDataSender.backup.connected} |
||
| 173 | session: ${sessions.0} |
||
| 174 | manager.length: ${manager.length} |
||
| 175 | manager.0.name: ${manager.0.name} |
||
| 176 | manager.1.name: ${manager.1.name} |
||
| 177 | hello: ${Hello} |
||
| 178 | manager.ClusterTest.0.name: ${manager.ClusterTest.0.name} |
||
| 179 | manager.ClusterTest.0.activeSessions: ${manager.ClusterTest.0.activeSessions} |
||
| 180 | manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED: |
||
| 181 | ${manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED} |
||
| 182 | manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS: |
||
| 183 | ${manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS} |
||
| 184 | </echo> |
||
| 185 | |||
| 186 | </target> |
||
| 187 | |||
| 188 | </project></code></pre></div> |
||
| 189 | <p><b>import:</b> Import the JMX Accessor Project with |
||
| 190 | <em><import file="${CATALINA.HOME}/bin/catalina-tasks.xml" /></em> and |
||
| 191 | reference the tasks with <em>jmxOpen</em>, <em>jmxSet</em>, <em>jmxGet</em>, |
||
| 192 | <em>jmxQuery</em>, <em>jmxInvoke</em>, <em>jmxEquals</em> and <em>jmxCondition</em>.</p> |
||
| 193 | |||
| 194 | </div><h3 id="JMXAccessorOpenTask_-_JMX_open_connection_task">JMXAccessorOpenTask - JMX open connection task</h3><div class="text"> |
||
| 195 | <p> |
||
| 196 | List of Attributes |
||
| 197 | </p> |
||
| 198 | <table class="defaultTable"> |
||
| 199 | |||
| 200 | <tr> |
||
| 201 | <th>Attribute</th> |
||
| 202 | <th>Description</th> |
||
| 203 | <th>Default value</th> |
||
| 204 | </tr> |
||
| 205 | |||
| 206 | <tr> |
||
| 207 | <td>url</td> |
||
| 208 | <td>Set JMX connection URL - <em>service:jmx:rmi:///jndi/rmi://localhost:8050/jmxrmi</em> |
||
| 209 | </td> |
||
| 210 | <td></td> |
||
| 211 | </tr> |
||
| 212 | |||
| 213 | <tr> |
||
| 214 | <td>host</td> |
||
| 215 | <td>Set the host, shortcut the very long URL syntax. |
||
| 216 | </td> |
||
| 217 | <td><code class="noHighlight">localhost</code></td> |
||
| 218 | </tr> |
||
| 219 | |||
| 220 | <tr> |
||
| 221 | <td>port</td> |
||
| 222 | <td>Set the remote connection port |
||
| 223 | </td> |
||
| 224 | <td><code class="noHighlight">8050</code></td> |
||
| 225 | </tr> |
||
| 226 | |||
| 227 | <tr> |
||
| 228 | <td>username</td> |
||
| 229 | <td>remote JMX connection user name. |
||
| 230 | </td> |
||
| 231 | <td></td> |
||
| 232 | </tr> |
||
| 233 | |||
| 234 | <tr> |
||
| 235 | <td>password</td> |
||
| 236 | <td>remote JMX connection password. |
||
| 237 | </td> |
||
| 238 | <td></td> |
||
| 239 | </tr> |
||
| 240 | |||
| 241 | <tr> |
||
| 242 | <td>ref</td> |
||
| 243 | <td>Name of the internal connection reference. With this attribute you can |
||
| 244 | configure more the one connection inside the same Ant project. |
||
| 245 | </td> |
||
| 246 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 247 | </tr> |
||
| 248 | |||
| 249 | <tr> |
||
| 250 | <td>echo</td> |
||
| 251 | <td>Echo the command usage (for access analysis or debugging) |
||
| 252 | </td> |
||
| 253 | <td><code class="noHighlight">false</code></td> |
||
| 254 | </tr> |
||
| 255 | |||
| 256 | <tr> |
||
| 257 | <td>if</td> |
||
| 258 | <td>Only execute if a property of the given name <b>exists</b> in the current project. |
||
| 259 | </td> |
||
| 260 | <td></td> |
||
| 261 | </tr> |
||
| 262 | |||
| 263 | <tr> |
||
| 264 | <td>unless</td> |
||
| 265 | <td>Only execute if a property of the given name <b>not exists</b> in the current project. |
||
| 266 | </td> |
||
| 267 | <td></td> |
||
| 268 | </tr> |
||
| 269 | |||
| 270 | </table> |
||
| 271 | |||
| 272 | <p> |
||
| 273 | Example to open a new JMX connection |
||
| 274 | </p> |
||
| 275 | <div class="codeBox"><pre><code> <jmx:open |
||
| 276 | host="${jmx.server.name}" |
||
| 277 | port="${jmx.server.port}" |
||
| 278 | /></code></pre></div> |
||
| 279 | |||
| 280 | <p> |
||
| 281 | Example to open a JMX connection from URL, with authorization and |
||
| 282 | store at other reference |
||
| 283 | </p> |
||
| 284 | <div class="codeBox"><pre><code> <jmx:open |
||
| 285 | url="service:jmx:rmi:///jndi/rmi://localhost:9024/jmxrmi" |
||
| 286 | ref="jmx.server.9024" |
||
| 287 | username="controlRole" |
||
| 288 | password="tomcat" |
||
| 289 | /></code></pre></div> |
||
| 290 | |||
| 291 | <p> |
||
| 292 | Example to open a JMX connection from URL, with authorization and |
||
| 293 | store at other reference, but only when property <em>jmx.if</em> exists and |
||
| 294 | <em>jmx.unless</em> not exists |
||
| 295 | </p> |
||
| 296 | <div class="codeBox"><pre><code> <jmx:open |
||
| 297 | url="service:jmx:rmi:///jndi/rmi://localhost:9024/jmxrmi" |
||
| 298 | ref="jmx.server.9024" |
||
| 299 | username="controlRole" |
||
| 300 | password="tomcat" |
||
| 301 | if="jmx.if" |
||
| 302 | unless="jmx.unless" |
||
| 303 | /></code></pre></div> |
||
| 304 | |||
| 305 | <p><b>Note</b>: All properties from <em>jmxOpen</em> task also exists at all |
||
| 306 | other tasks and conditions. |
||
| 307 | </p> |
||
| 308 | |||
| 309 | </div><h3 id="JMXAccessorGetTask:__get_attribute_value_Ant_task">JMXAccessorGetTask: get attribute value Ant task</h3><div class="text"> |
||
| 310 | <p> |
||
| 311 | List of Attributes |
||
| 312 | </p> |
||
| 313 | <table class="defaultTable"> |
||
| 314 | |||
| 315 | <tr> |
||
| 316 | <th>Attribute</th> |
||
| 317 | <th>Description</th> |
||
| 318 | <th>Default value</th> |
||
| 319 | </tr> |
||
| 320 | |||
| 321 | <tr> |
||
| 322 | <td>name</td> |
||
| 323 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=Server</em> |
||
| 324 | </td> |
||
| 325 | <td></td> |
||
| 326 | </tr> |
||
| 327 | |||
| 328 | <tr> |
||
| 329 | <td>attribute</td> |
||
| 330 | <td>Existing MBean attribute (see Tomcat MBean description above) |
||
| 331 | </td> |
||
| 332 | <td></td> |
||
| 333 | </tr> |
||
| 334 | |||
| 335 | <tr> |
||
| 336 | <td>ref</td> |
||
| 337 | <td>JMX Connection reference |
||
| 338 | </td> |
||
| 339 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 340 | </tr> |
||
| 341 | |||
| 342 | <tr> |
||
| 343 | <td>echo</td> |
||
| 344 | <td>Echo command usage (access and result) |
||
| 345 | </td> |
||
| 346 | <td><code class="noHighlight">false</code></td> |
||
| 347 | </tr> |
||
| 348 | |||
| 349 | <tr> |
||
| 350 | <td>resultproperty</td> |
||
| 351 | <td>Save result at this project property |
||
| 352 | </td> |
||
| 353 | <td></td> |
||
| 354 | </tr> |
||
| 355 | |||
| 356 | <tr> |
||
| 357 | <td>delimiter</td> |
||
| 358 | <td>Split result with delimiter (java.util.StringTokenizer) |
||
| 359 | and use resultproperty as prefix to store tokens. |
||
| 360 | </td> |
||
| 361 | <td></td> |
||
| 362 | </tr> |
||
| 363 | |||
| 364 | <tr> |
||
| 365 | <td>separatearrayresults</td> |
||
| 366 | <td>When return value is an array, save result as property list |
||
| 367 | (<em>$resultproperty.[0..N]</em> and <em>$resultproperty.length</em>) |
||
| 368 | </td> |
||
| 369 | <td><code class="noHighlight">true</code></td> |
||
| 370 | </tr> |
||
| 371 | |||
| 372 | </table> |
||
| 373 | |||
| 374 | <p> |
||
| 375 | Example to get remote MBean attribute from default JMX connection |
||
| 376 | </p> |
||
| 377 | <div class="codeBox"><pre><code> <jmx:get |
||
| 378 | name="Catalina:type=Manager,context=/servlets-examples,host=localhost" |
||
| 379 | attribute="maxActiveSessions" |
||
| 380 | resultproperty="servlets-examples.maxActiveSessions" |
||
| 381 | /></code></pre></div> |
||
| 382 | |||
| 383 | <p> |
||
| 384 | Example to get and result array and split it at separate properties |
||
| 385 | </p> |
||
| 386 | <div class="codeBox"><pre><code> <jmx:get |
||
| 387 | name="Catalina:type=ClusterSender,host=localhost" |
||
| 388 | attribute="senderObjectNames" |
||
| 389 | resultproperty="senderObjectNames" |
||
| 390 | /></code></pre></div> |
||
| 391 | <p> |
||
| 392 | Access the senderObjectNames properties with: |
||
| 393 | </p> |
||
| 394 | <div class="codeBox"><pre><code> ${senderObjectNames.length} give the number of returned sender list. |
||
| 395 | ${senderObjectNames.[0..N]} found all sender object names</code></pre></div> |
||
| 396 | |||
| 397 | |||
| 398 | <p> |
||
| 399 | Example to get IDataSender attribute connected only when cluster is configured.<br> |
||
| 400 | <em>Note:</em> The <code>name</code> attribute value was wrapped here to be |
||
| 401 | more readable. It has to be all on the same line, without spaces. |
||
| 402 | </p> |
||
| 403 | <div class="codeBox"><pre><code> |
||
| 404 | <jmx:query |
||
| 405 | failonerror="false" |
||
| 406 | name="Catalina:type=Cluster,host=${tomcat.application.host}" |
||
| 407 | resultproperty="cluster" |
||
| 408 | /> |
||
| 409 | <jmx:get |
||
| 410 | name= |
||
| 411 | "Catalina:type=IDataSender,host=${tomcat.application.host}, |
||
| 412 | senderAddress=${cluster.backup.address},senderPort=${cluster.backup.port}" |
||
| 413 | attribute="connected" |
||
| 414 | resultproperty="datasender.connected" |
||
| 415 | if="cluster.0.name" /></code></pre></div> |
||
| 416 | |||
| 417 | </div><h3 id="JMXAccessorSetTask:__set_attribute_value_Ant_task">JMXAccessorSetTask: set attribute value Ant task</h3><div class="text"> |
||
| 418 | <p> |
||
| 419 | List of Attributes |
||
| 420 | </p> |
||
| 421 | <table class="defaultTable"> |
||
| 422 | |||
| 423 | <tr> |
||
| 424 | <th>Attribute</th> |
||
| 425 | <th>Description</th> |
||
| 426 | <th>Default value</th> |
||
| 427 | </tr> |
||
| 428 | |||
| 429 | <tr> |
||
| 430 | <td>name</td> |
||
| 431 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=Server</em> |
||
| 432 | </td> |
||
| 433 | <td></td> |
||
| 434 | </tr> |
||
| 435 | |||
| 436 | <tr> |
||
| 437 | <td>attribute</td> |
||
| 438 | <td>Existing MBean attribute (see Tomcat MBean description above) |
||
| 439 | </td> |
||
| 440 | <td></td> |
||
| 441 | </tr> |
||
| 442 | |||
| 443 | <tr> |
||
| 444 | <td>value</td> |
||
| 445 | <td>value that set to attribute |
||
| 446 | </td> |
||
| 447 | <td></td> |
||
| 448 | </tr> |
||
| 449 | |||
| 450 | <tr> |
||
| 451 | <td>type</td> |
||
| 452 | <td>type of the attribute. |
||
| 453 | </td> |
||
| 454 | <td><code class="noHighlight">java.lang.String</code></td> |
||
| 455 | </tr> |
||
| 456 | |||
| 457 | <tr> |
||
| 458 | <td>ref</td> |
||
| 459 | <td>JMX Connection reference |
||
| 460 | </td> |
||
| 461 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 462 | </tr> |
||
| 463 | |||
| 464 | <tr> |
||
| 465 | <td>echo</td> |
||
| 466 | <td>Echo command usage (access and result) |
||
| 467 | </td> |
||
| 468 | <td><code class="noHighlight">false</code></td> |
||
| 469 | </tr> |
||
| 470 | |||
| 471 | </table> |
||
| 472 | |||
| 473 | <p> |
||
| 474 | Example to set remote MBean attribute value |
||
| 475 | </p> |
||
| 476 | <div class="codeBox"><pre><code> <jmx:set |
||
| 477 | name="Catalina:type=Manager,context=/servlets-examples,host=localhost" |
||
| 478 | attribute="maxActiveSessions" |
||
| 479 | value="500" |
||
| 480 | type="int" |
||
| 481 | /></code></pre></div> |
||
| 482 | |||
| 483 | |||
| 484 | </div><h3 id="JMXAccessorInvokeTask:__invoke_MBean_operation_Ant_task">JMXAccessorInvokeTask: invoke MBean operation Ant task</h3><div class="text"> |
||
| 485 | <p> |
||
| 486 | List of Attributes |
||
| 487 | </p> |
||
| 488 | <table class="defaultTable"> |
||
| 489 | |||
| 490 | <tr> |
||
| 491 | <th>Attribute</th> |
||
| 492 | <th>Description</th> |
||
| 493 | <th>Default value</th> |
||
| 494 | </tr> |
||
| 495 | |||
| 496 | <tr> |
||
| 497 | <td>name</td> |
||
| 498 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=Server</em> |
||
| 499 | </td> |
||
| 500 | <td></td> |
||
| 501 | </tr> |
||
| 502 | |||
| 503 | <tr> |
||
| 504 | <td>operation</td> |
||
| 505 | <td>Existing MBean operation |
||
| 506 | </td> |
||
| 507 | <td></td> |
||
| 508 | </tr> |
||
| 509 | |||
| 510 | <tr> |
||
| 511 | <td>ref</td> |
||
| 512 | <td>JMX Connection reference |
||
| 513 | </td> |
||
| 514 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 515 | </tr> |
||
| 516 | |||
| 517 | <tr> |
||
| 518 | <td>echo</td> |
||
| 519 | <td>Echo command usage (access and result) |
||
| 520 | </td> |
||
| 521 | <td><code class="noHighlight">false</code></td> |
||
| 522 | </tr> |
||
| 523 | |||
| 524 | <tr> |
||
| 525 | <td>resultproperty</td> |
||
| 526 | <td>Save result at this project property |
||
| 527 | </td> |
||
| 528 | <td></td> |
||
| 529 | </tr> |
||
| 530 | |||
| 531 | <tr> |
||
| 532 | <td>delimiter</td> |
||
| 533 | <td>Split result with delimiter (java.util.StringTokenizer) |
||
| 534 | and use resultproperty as prefix to store tokens. |
||
| 535 | </td> |
||
| 536 | <td></td> |
||
| 537 | </tr> |
||
| 538 | |||
| 539 | <tr> |
||
| 540 | <td>separatearrayresults</td> |
||
| 541 | <td>When return value is an array, save result as property list |
||
| 542 | (<em>$resultproperty.[0..N]</em> and <em>$resultproperty.length</em>) |
||
| 543 | </td> |
||
| 544 | <td><code class="noHighlight">true</code></td> |
||
| 545 | </tr> |
||
| 546 | |||
| 547 | </table> |
||
| 548 | |||
| 549 | <p> |
||
| 550 | stop an application |
||
| 551 | </p> |
||
| 552 | <div class="codeBox"><pre><code> <jmx:invoke |
||
| 553 | name="Catalina:type=Manager,context=/servlets-examples,host=localhost" |
||
| 554 | operation="stop"/></code></pre></div> |
||
| 555 | <p> |
||
| 556 | Now you can find the sessionid at <em>${sessions.[0..N}</em> properties and access the count |
||
| 557 | with ${sessions.length} property. |
||
| 558 | </p> |
||
| 559 | <p> |
||
| 560 | Example to get all sessionids |
||
| 561 | </p> |
||
| 562 | <div class="codeBox"><pre><code> <jmx:invoke |
||
| 563 | name="Catalina:type=Manager,context=/servlets-examples,host=localhost" |
||
| 564 | operation="listSessionIds" |
||
| 565 | resultproperty="sessions" |
||
| 566 | delimiter=" " |
||
| 567 | /></code></pre></div> |
||
| 568 | <p> |
||
| 569 | Now you can find the sessionid at <em>${sessions.[0..N}</em> properties and access the count |
||
| 570 | with ${sessions.length} property. |
||
| 571 | </p> |
||
| 572 | <p> |
||
| 573 | Example to get remote MBean session attribute from session ${sessionid.0} |
||
| 574 | </p> |
||
| 575 | <div class="codeBox"><pre><code> <jmx:invoke |
||
| 576 | name="Catalina:type=Manager,context=/ClusterTest,host=localhost" |
||
| 577 | operation="getSessionAttribute" |
||
| 578 | resultproperty="hello"> |
||
| 579 | <arg value="${sessionid.0}"/> |
||
| 580 | <arg value="Hello" /> |
||
| 581 | </jmx:invoke></code></pre></div> |
||
| 582 | |||
| 583 | <p> |
||
| 584 | Example to create a new access logger valve at vhost <em>localhost</em> |
||
| 585 | </p> |
||
| 586 | <div class="codeBox"><pre><code> <jmx:invoke |
||
| 587 | name="Catalina:type=MBeanFactory" |
||
| 588 | operation="createAccessLoggerValve" |
||
| 589 | resultproperty="accessLoggerObjectName" |
||
| 590 | > |
||
| 591 | <arg value="Catalina:type=Host,host=localhost"/> |
||
| 592 | </jmx:invoke></code></pre></div> |
||
| 593 | <p> |
||
| 594 | Now you can find new MBean with name stored at <em>${accessLoggerObjectName}</em> |
||
| 595 | property. |
||
| 596 | </p> |
||
| 597 | |||
| 598 | </div><h3 id="JMXAccessorQueryTask:__query_MBean_Ant_task">JMXAccessorQueryTask: query MBean Ant task</h3><div class="text"> |
||
| 599 | <p> |
||
| 600 | List of Attributes |
||
| 601 | </p> |
||
| 602 | <table class="defaultTable"> |
||
| 603 | |||
| 604 | <tr> |
||
| 605 | <th>Attribute</th> |
||
| 606 | <th>Description</th> |
||
| 607 | <th>Default value</th> |
||
| 608 | </tr> |
||
| 609 | |||
| 610 | <tr> |
||
| 611 | <td>name</td> |
||
| 612 | <td>JMX ObjectName query string -- <em>Catalina:type=Manager,*</em> |
||
| 613 | </td> |
||
| 614 | <td></td> |
||
| 615 | </tr> |
||
| 616 | |||
| 617 | <tr> |
||
| 618 | <td>ref</td> |
||
| 619 | <td>JMX Connection reference |
||
| 620 | </td> |
||
| 621 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 622 | </tr> |
||
| 623 | |||
| 624 | <tr> |
||
| 625 | <td>echo</td> |
||
| 626 | <td>Echo command usage (access and result) |
||
| 627 | </td> |
||
| 628 | <td><code class="noHighlight">false</code></td> |
||
| 629 | </tr> |
||
| 630 | |||
| 631 | <tr> |
||
| 632 | <td>resultproperty</td> |
||
| 633 | <td>Prefix project property name to all founded MBeans (<em>mbeans.[0..N].objectname</em>) |
||
| 634 | </td> |
||
| 635 | <td></td> |
||
| 636 | </tr> |
||
| 637 | |||
| 638 | <tr> |
||
| 639 | <td>attributebinding</td> |
||
| 640 | <td>bind ALL MBean attributes in addition to <em>name</em> |
||
| 641 | </td> |
||
| 642 | <td><code class="noHighlight">false</code></td> |
||
| 643 | </tr> |
||
| 644 | |||
| 645 | <tr> |
||
| 646 | <td>delimiter</td> |
||
| 647 | <td>Split result with delimiter (java.util.StringTokenizer) |
||
| 648 | and use resultproperty as prefix to store tokens. |
||
| 649 | </td> |
||
| 650 | <td></td> |
||
| 651 | </tr> |
||
| 652 | |||
| 653 | <tr> |
||
| 654 | <td>separatearrayresults</td> |
||
| 655 | <td>When return value is an array, save result as property list |
||
| 656 | (<em>$resultproperty.[0..N]</em> and <em>$resultproperty.length</em>) |
||
| 657 | </td> |
||
| 658 | <td><code class="noHighlight">true</code></td> |
||
| 659 | </tr> |
||
| 660 | |||
| 661 | </table> |
||
| 662 | |||
| 663 | <p> |
||
| 664 | Get all Manager ObjectNames from all services and Hosts |
||
| 665 | </p> |
||
| 666 | <div class="codeBox"><pre><code> <jmx:query |
||
| 667 | name="Catalina:type=Manager,* |
||
| 668 | resultproperty="manager" /></code></pre></div> |
||
| 669 | <p> |
||
| 670 | Now you can find the Session Manager at <em>${manager.[0..N].name}</em> |
||
| 671 | properties and access the result object counter with ${manager.length} property. |
||
| 672 | </p> |
||
| 673 | <p> |
||
| 674 | Example to get the Manager from <em>servlet-examples</em> application an bind all MBean properties |
||
| 675 | </p> |
||
| 676 | <div class="codeBox"><pre><code> <jmx:query |
||
| 677 | name="Catalina:type=Manager,context=/servlet-examples,host=localhost*" |
||
| 678 | attributebinding="true" |
||
| 679 | resultproperty="manager.servletExamples" /></code></pre></div> |
||
| 680 | <p> |
||
| 681 | Now you can find the manager at <em>${manager.servletExamples.0.name}</em> property |
||
| 682 | and can access all properties from this manager with <em>${manager.servletExamples.0.[manager attribute names]</em>}. |
||
| 683 | The result object counter from MBeans is stored ad ${manager.length} property. |
||
| 684 | </p> |
||
| 685 | |||
| 686 | <p> |
||
| 687 | Example to get all MBeans from a server and store inside an external XML property file |
||
| 688 | </p> |
||
| 689 | <div class="codeBox"><pre><code><project name="jmx.query" |
||
| 690 | xmlns:jmx="antlib:org.apache.catalina.ant.jmx" |
||
| 691 | default="query-all" basedir="."> |
||
| 692 | <property name="jmx.host" value="localhost"/> |
||
| 693 | <property name="jmx.port" value="8050"/> |
||
| 694 | <property name="jmx.username" value="controlRole"/> |
||
| 695 | <property name="jmx.password" value="tomcat"/> |
||
| 696 | |||
| 697 | <target name="query-all" description="Query all MBeans of a server"> |
||
| 698 | <!-- Configure connection --> |
||
| 699 | <jmx:open |
||
| 700 | host="${jmx.host}" |
||
| 701 | port="${jmx.port}" |
||
| 702 | ref="jmx.server" |
||
| 703 | username="${jmx.username}" |
||
| 704 | password="${jmx.password}"/> |
||
| 705 | |||
| 706 | <!-- Query MBean list --> |
||
| 707 | <jmx:query |
||
| 708 | name="*:*" |
||
| 709 | resultproperty="mbeans" |
||
| 710 | attributebinding="false"/> |
||
| 711 | |||
| 712 | <echoproperties |
||
| 713 | destfile="mbeans.properties" |
||
| 714 | prefix="mbeans." |
||
| 715 | format="xml"/> |
||
| 716 | |||
| 717 | <!-- Print results --> |
||
| 718 | <echo message= |
||
| 719 | "Number of MBeans in server ${jmx.host}:${jmx.port} is ${mbeans.length}"/> |
||
| 720 | </target> |
||
| 721 | </project></code></pre></div> |
||
| 722 | <p> |
||
| 723 | Now you can find all MBeans inside the file <em>mbeans.properties</em>. |
||
| 724 | </p> |
||
| 725 | |||
| 726 | </div><h3 id="JMXAccessorCreateTask:__remote_create_MBean_Ant_task">JMXAccessorCreateTask: remote create MBean Ant task</h3><div class="text"> |
||
| 727 | <p> |
||
| 728 | List of Attributes |
||
| 729 | </p> |
||
| 730 | <table class="defaultTable"> |
||
| 731 | |||
| 732 | <tr> |
||
| 733 | <th>Attribute</th> |
||
| 734 | <th>Description</th> |
||
| 735 | <th>Default value</th> |
||
| 736 | </tr> |
||
| 737 | |||
| 738 | <tr> |
||
| 739 | <td>name</td> |
||
| 740 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=MBeanFactory</em> |
||
| 741 | </td> |
||
| 742 | <td></td> |
||
| 743 | </tr> |
||
| 744 | |||
| 745 | <tr> |
||
| 746 | <td>className</td> |
||
| 747 | <td>Existing MBean full qualified class name (see Tomcat MBean description above) |
||
| 748 | </td> |
||
| 749 | <td></td> |
||
| 750 | </tr> |
||
| 751 | |||
| 752 | <tr> |
||
| 753 | <td>classLoader</td> |
||
| 754 | <td>ObjectName of server or web application classloader <br> |
||
| 755 | ( <em>Catalina:type=ServerClassLoader,name=[server,common,shared]</em> or<br> |
||
| 756 | <em>Catalina:type=WebappClassLoader,context=/myapps,host=localhost</em>) |
||
| 757 | </td> |
||
| 758 | <td></td> |
||
| 759 | </tr> |
||
| 760 | |||
| 761 | <tr> |
||
| 762 | <td>ref</td> |
||
| 763 | <td>JMX Connection reference |
||
| 764 | </td> |
||
| 765 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 766 | </tr> |
||
| 767 | |||
| 768 | <tr> |
||
| 769 | <td>echo</td> |
||
| 770 | <td>Echo command usage (access and result) |
||
| 771 | </td> |
||
| 772 | <td><code class="noHighlight">false</code></td> |
||
| 773 | </tr> |
||
| 774 | |||
| 775 | </table> |
||
| 776 | |||
| 777 | <p> |
||
| 778 | Example to create remote MBean |
||
| 779 | </p> |
||
| 780 | <div class="codeBox"><pre><code> <jmx:create |
||
| 781 | ref="${jmx.reference}" |
||
| 782 | name="Catalina:type=MBeanFactory" |
||
| 783 | className="org.apache.commons.modeler.BaseModelMBean" |
||
| 784 | classLoader="Catalina:type=ServerClassLoader,name=server"> |
||
| 785 | <arg value="org.apache.catalina.mbeans.MBeanFactory" /> |
||
| 786 | </jmx:create></code></pre></div> |
||
| 787 | |||
| 788 | <p> |
||
| 789 | <b>Warning</b>: Many Tomcat MBeans can't be linked to their parent once<br> |
||
| 790 | created. The Valve, Cluster and Realm MBeans are not automatically<br> |
||
| 791 | connected with their parent. Use the <em>MBeanFactory</em> create<br> |
||
| 792 | operation instead. |
||
| 793 | </p> |
||
| 794 | |||
| 795 | </div><h3 id="JMXAccessorUnregisterTask:__remote_unregister_MBean_Ant_task">JMXAccessorUnregisterTask: remote unregister MBean Ant task</h3><div class="text"> |
||
| 796 | <p> |
||
| 797 | List of Attributes |
||
| 798 | </p> |
||
| 799 | <table class="defaultTable"> |
||
| 800 | |||
| 801 | <tr> |
||
| 802 | <th>Attribute</th> |
||
| 803 | <th>Description</th> |
||
| 804 | <th>Default value</th> |
||
| 805 | </tr> |
||
| 806 | |||
| 807 | <tr> |
||
| 808 | <td>name</td> |
||
| 809 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=MBeanFactory</em> |
||
| 810 | </td> |
||
| 811 | <td></td> |
||
| 812 | </tr> |
||
| 813 | |||
| 814 | <tr> |
||
| 815 | <td>ref</td> |
||
| 816 | <td>JMX Connection reference |
||
| 817 | </td> |
||
| 818 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 819 | </tr> |
||
| 820 | |||
| 821 | <tr> |
||
| 822 | <td>echo</td> |
||
| 823 | <td>Echo command usage (access and result) |
||
| 824 | </td> |
||
| 825 | <td><code class="noHighlight">false</code></td> |
||
| 826 | </tr> |
||
| 827 | |||
| 828 | </table> |
||
| 829 | |||
| 830 | <p> |
||
| 831 | Example to unregister remote MBean |
||
| 832 | </p> |
||
| 833 | <div class="codeBox"><pre><code> <jmx:unregister |
||
| 834 | name="Catalina:type=MBeanFactory" |
||
| 835 | /></code></pre></div> |
||
| 836 | |||
| 837 | <p> |
||
| 838 | <b>Warning</b>: A lot of Tomcat MBeans can't be unregister.<br> |
||
| 839 | The MBeans are not unlinked from their parent. Use <em>MBeanFactory</em><br> |
||
| 840 | remove operation instead. |
||
| 841 | </p> |
||
| 842 | |||
| 843 | </div><h3 id="JMXAccessorCondition:__express_condition">JMXAccessorCondition: express condition</h3><div class="text"> |
||
| 844 | <p> |
||
| 845 | List of Attributes |
||
| 846 | </p> |
||
| 847 | <table class="defaultTable"> |
||
| 848 | |||
| 849 | <tr> |
||
| 850 | <th>Attribute</th> |
||
| 851 | <th>Description</th> |
||
| 852 | <th>Default value</th> |
||
| 853 | </tr> |
||
| 854 | |||
| 855 | <tr> |
||
| 856 | <td>url</td> |
||
| 857 | <td>Set JMX connection URL - <em>service:jmx:rmi:///jndi/rmi://localhost:8050/jmxrmi</em> |
||
| 858 | </td> |
||
| 859 | <td></td> |
||
| 860 | </tr> |
||
| 861 | |||
| 862 | <tr> |
||
| 863 | <td>host</td> |
||
| 864 | <td>Set the host, shortcut the very long URL syntax. |
||
| 865 | </td> |
||
| 866 | <td><code class="noHighlight">localhost</code></td> |
||
| 867 | </tr> |
||
| 868 | |||
| 869 | <tr> |
||
| 870 | <td>port</td> |
||
| 871 | <td>Set the remote connection port |
||
| 872 | </td> |
||
| 873 | <td><code class="noHighlight">8050</code></td> |
||
| 874 | </tr> |
||
| 875 | |||
| 876 | <tr> |
||
| 877 | <td>username</td> |
||
| 878 | <td>remote JMX connection user name. |
||
| 879 | </td> |
||
| 880 | <td></td> |
||
| 881 | </tr> |
||
| 882 | |||
| 883 | <tr> |
||
| 884 | <td>password</td> |
||
| 885 | <td>remote JMX connection password. |
||
| 886 | </td> |
||
| 887 | <td></td> |
||
| 888 | </tr> |
||
| 889 | |||
| 890 | <tr> |
||
| 891 | <td>ref</td> |
||
| 892 | <td>Name of the internal connection reference. With this attribute you can |
||
| 893 | configure more the one connection inside the same Ant project. |
||
| 894 | </td> |
||
| 895 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 896 | </tr> |
||
| 897 | |||
| 898 | <tr> |
||
| 899 | <td>name</td> |
||
| 900 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=Server</em> |
||
| 901 | </td> |
||
| 902 | <td></td> |
||
| 903 | </tr> |
||
| 904 | |||
| 905 | <tr> |
||
| 906 | <td>echo</td> |
||
| 907 | <td>Echo condition usage (access and result) |
||
| 908 | </td> |
||
| 909 | <td><code class="noHighlight">false</code></td> |
||
| 910 | </tr> |
||
| 911 | |||
| 912 | <tr> |
||
| 913 | <td>if</td> |
||
| 914 | <td>Only execute if a property of the given name <b>exists</b> in the current project. |
||
| 915 | </td> |
||
| 916 | <td></td> |
||
| 917 | </tr> |
||
| 918 | |||
| 919 | <tr> |
||
| 920 | <td>unless</td> |
||
| 921 | <td>Only execute if a property of the given name <b>not exists</b> in the current project. |
||
| 922 | </td> |
||
| 923 | <td></td> |
||
| 924 | </tr> |
||
| 925 | |||
| 926 | <tr> |
||
| 927 | <td>value (required)</td> |
||
| 928 | <td>Second arg for operation |
||
| 929 | </td> |
||
| 930 | <td></td> |
||
| 931 | </tr> |
||
| 932 | |||
| 933 | <tr> |
||
| 934 | <td>type</td> |
||
| 935 | <td>Value type to express operation (support <em>long</em> and <em>double</em>) |
||
| 936 | </td> |
||
| 937 | <td><code class="noHighlight">long</code></td> |
||
| 938 | </tr> |
||
| 939 | |||
| 940 | <tr> |
||
| 941 | <td>operation</td> |
||
| 942 | <td> express one |
||
| 943 | <ul> |
||
| 944 | <li>== equals</li> |
||
| 945 | <li>!= not equals</li> |
||
| 946 | <li>> greater than (&gt;)</li> |
||
| 947 | <li>>= greater than or equals (&gt;=)</li> |
||
| 948 | <li>< lesser than (&lt;)</li> |
||
| 949 | <li><= lesser than or equals (&lt;=)</li> |
||
| 950 | </ul> |
||
| 951 | </td> |
||
| 952 | <td><code class="noHighlight">==</code></td> |
||
| 953 | </tr> |
||
| 954 | |||
| 955 | </table> |
||
| 956 | |||
| 957 | <p> |
||
| 958 | Wait for server connection and that cluster backup node is accessible |
||
| 959 | </p> |
||
| 960 | <div class="codeBox"><pre><code><target name="wait"> |
||
| 961 | <waitfor maxwait="${maxwait}" maxwaitunit="second" timeoutproperty="server.timeout" > |
||
| 962 | <and> |
||
| 963 | <socket server="${server.name}" port="${server.port}"/> |
||
| 964 | <http url="${url}"/> |
||
| 965 | <jmx:condition |
||
| 966 | operation="==" |
||
| 967 | host="localhost" |
||
| 968 | port="9014" |
||
| 969 | username="controlRole" |
||
| 970 | password="tomcat" |
||
| 971 | name= |
||
| 972 | "Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025" |
||
| 973 | attribute="connected" |
||
| 974 | value="true" |
||
| 975 | /> |
||
| 976 | </and> |
||
| 977 | </waitfor> |
||
| 978 | <fail if="server.timeout" message="Server ${url} don't answer inside ${maxwait} sec" /> |
||
| 979 | <echo message="Server ${url} alive" /> |
||
| 980 | </target></code></pre></div> |
||
| 981 | |||
| 982 | </div><h3 id="JMXAccessorEqualsCondition:__equals_MBean_Ant_condition">JMXAccessorEqualsCondition: equals MBean Ant condition</h3><div class="text"> |
||
| 983 | <p> |
||
| 984 | List of Attributes |
||
| 985 | </p> |
||
| 986 | <table class="defaultTable"> |
||
| 987 | |||
| 988 | <tr> |
||
| 989 | <th>Attribute</th> |
||
| 990 | <th>Description</th> |
||
| 991 | <th>Default value</th> |
||
| 992 | </tr> |
||
| 993 | |||
| 994 | <tr> |
||
| 995 | <td>url</td> |
||
| 996 | <td>Set JMX connection URL - <em>service:jmx:rmi:///jndi/rmi://localhost:8050/jmxrmi</em> |
||
| 997 | </td> |
||
| 998 | <td></td> |
||
| 999 | </tr> |
||
| 1000 | |||
| 1001 | <tr> |
||
| 1002 | <td>host</td> |
||
| 1003 | <td>Set the host, shortcut the very long URL syntax. |
||
| 1004 | </td> |
||
| 1005 | <td><code class="noHighlight">localhost</code></td> |
||
| 1006 | </tr> |
||
| 1007 | |||
| 1008 | <tr> |
||
| 1009 | <td>port</td> |
||
| 1010 | <td>Set the remote connection port |
||
| 1011 | </td> |
||
| 1012 | <td><code class="noHighlight">8050</code></td> |
||
| 1013 | </tr> |
||
| 1014 | |||
| 1015 | <tr> |
||
| 1016 | <td>username</td> |
||
| 1017 | <td>remote JMX connection user name. |
||
| 1018 | </td> |
||
| 1019 | <td></td> |
||
| 1020 | </tr> |
||
| 1021 | |||
| 1022 | <tr> |
||
| 1023 | <td>password</td> |
||
| 1024 | <td>remote JMX connection password. |
||
| 1025 | </td> |
||
| 1026 | <td></td> |
||
| 1027 | </tr> |
||
| 1028 | |||
| 1029 | <tr> |
||
| 1030 | <td>ref</td> |
||
| 1031 | <td>Name of the internal connection reference. With this attribute you can |
||
| 1032 | configure more the one connection inside the same Ant project. |
||
| 1033 | </td> |
||
| 1034 | <td><code class="noHighlight">jmx.server</code></td> |
||
| 1035 | </tr> |
||
| 1036 | |||
| 1037 | <tr> |
||
| 1038 | <td>name</td> |
||
| 1039 | <td>Full qualified JMX ObjectName -- <em>Catalina:type=Server</em> |
||
| 1040 | </td> |
||
| 1041 | <td></td> |
||
| 1042 | </tr> |
||
| 1043 | |||
| 1044 | |||
| 1045 | <tr> |
||
| 1046 | <td>echo</td> |
||
| 1047 | <td>Echo condition usage (access and result) |
||
| 1048 | </td> |
||
| 1049 | <td><code class="noHighlight">false</code></td> |
||
| 1050 | </tr> |
||
| 1051 | |||
| 1052 | </table> |
||
| 1053 | |||
| 1054 | <p> |
||
| 1055 | Wait for server connection and that cluster backup node is accessible |
||
| 1056 | </p> |
||
| 1057 | <div class="codeBox"><pre><code><target name="wait"> |
||
| 1058 | <waitfor maxwait="${maxwait}" maxwaitunit="second" timeoutproperty="server.timeout" > |
||
| 1059 | <and> |
||
| 1060 | <socket server="${server.name}" port="${server.port}"/> |
||
| 1061 | <http url="${url}"/> |
||
| 1062 | <jmx:equals |
||
| 1063 | host="localhost" |
||
| 1064 | port="9014" |
||
| 1065 | username="controlRole" |
||
| 1066 | password="tomcat" |
||
| 1067 | name= |
||
| 1068 | "Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025" |
||
| 1069 | attribute="connected" |
||
| 1070 | value="true" |
||
| 1071 | /> |
||
| 1072 | </and> |
||
| 1073 | </waitfor> |
||
| 1074 | <fail if="server.timeout" message="Server ${url} don't answer inside ${maxwait} sec" /> |
||
| 1075 | <echo message="Server ${url} alive" /> |
||
| 1076 | </target></code></pre></div> |
||
| 1077 | |||
| 1078 | </div><h3 id="Using_the_JMXProxyServlet">Using the JMXProxyServlet</h3><div class="text"> |
||
| 1079 | |||
| 1080 | <p> |
||
| 1081 | Tomcat offers an alternative to using remote (or even local) JMX |
||
| 1082 | connections while still giving you access to everything JMX has to offer: |
||
| 1083 | Tomcat's |
||
| 1084 | <a href="api/org/apache/catalina/manager/JMXProxyServlet.html">JMXProxyServlet</a>. |
||
| 1085 | </p> |
||
| 1086 | |||
| 1087 | <p> |
||
| 1088 | The JMXProxyServlet allows a client to issue JMX queries via an HTTP |
||
| 1089 | interface. This technique offers the following advantages over using |
||
| 1090 | JMX directly from a client program: |
||
| 1091 | </p> |
||
| 1092 | |||
| 1093 | <ul> |
||
| 1094 | <li>You don't have to launch a full JVM and make a remote JMX connection |
||
| 1095 | just to ask for one small piece of data from a running server</li> |
||
| 1096 | <li>You don't have to know how to work with JMX connections</li> |
||
| 1097 | <li>You don't need any of the complex configuration covered in the rest |
||
| 1098 | of this page</li> |
||
| 1099 | <li>Your client program does not have to be written in Java</li> |
||
| 1100 | </ul> |
||
| 1101 | |||
| 1102 | <p> |
||
| 1103 | A perfect example of JMX overkill can be seen in the case of popular |
||
| 1104 | server-monitoring software such as Nagios or Icinga: if you want to |
||
| 1105 | monitor 10 items via JMX, you will have to launch 10 JVMs, make 10 JMX |
||
| 1106 | connections, and then shut them all down every few minutes. With the |
||
| 1107 | JMXProxyServlet, you can make 10 HTTP connections and be done with it. |
||
| 1108 | </p> |
||
| 1109 | |||
| 1110 | <p> |
||
| 1111 | You can find out more information about the JMXProxyServlet in the |
||
| 1112 | documentation for the |
||
| 1113 | <a href="manager-howto.html#Using_the_JMX_Proxy_Servlet">Tomcat |
||
| 1114 | manager</a>. |
||
| 1115 | </p> |
||
| 1116 | </div></div></div></div></div><footer><div id="footer"> |
||
| 1117 | Copyright © 1999-2025, The Apache Software Foundation |
||
| 1118 | <br> |
||
| 1119 | Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo |
||
| 1120 | are either registered trademarks or trademarks of the Apache Software |
||
| 1121 | Foundation. |
||
| 1122 | </div></footer></div></body></html> |