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