Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > c27466c2a3fa3cf6008c3a485d00ce04 > files > 108

jetty5-manual-5.1.15-1.5.2mdv2010.0.noarch.rpm

SECTION: 250-Configuration
TITLE: 300stats
QUESTION: Does Jetty support statistics gathering?

<p>
There are 2 sets of statistics available with Jetty. One is Jetty-specific, and the other conforms to the <A HREF="http://www.jcp.org/en/jsr/detail?id=77">JSR77</A> specification.
Both are accessible via the JMX console (see the <a href="readme.txt">README.TXT</a> file for instructions on how to start Jetty with JMX) and the API.
</p>

<p/>
<B>Extended Jetty Statistics</B>
<p>
To enable the Jetty-specific statistics, set <code>statsOn</code> to <code>true</code> in your Jetty configuration xml file before starting Jetty. 
There is an example of this in <code>$JETTY_HOME/etc/jetty.xml</code>. The relevant line is:
<pre>
<code>
  &lt;Set name="statsOn"&gt;true&lt;/Set&gt;
</code>
</pre>
You can also control statistics at runtime by using the JMX console or the API to call methods on the Server instance to:
<ul>
  <li>disable statistics (<code>setStatsOn(false)</code>)
  <li>(re)enable statistics (<code>setStatsOn(true)</code>)
  <li>reset the statistics counters (<code>statsReset()</code>)
</ul>

Statistics are gathered on a per-Server instance basis. Here are some of the statistics that Jetty will capture:
<ul>
  <li><code>connections</code> - the number of connections accepted
  <li><code>connectionsOpen</code> - the number of currently open connections
  <li><code>connectionsOpenMax</code> - the max number of concurrently open connections
  <li><code>connectionsDurationAve</code> - sliding average duration in milliseconds of open connections
  <li><code>connectionsDurationMax</code> - maximum duration in milliseconds of an open connection
  <li><code>connectionsRequestsAve</code> - sliding average number of requests per connection
  <li><code>connectionsRequestsMax</code> - maximum number of requests per connection
  <li><code>errors</code> - number of errors generated while handling requests
  <li><code>requests</code> - number of requests
  <li><code>requestsActive</code> - number of requests currently active
  <li><code>requestsActiveMax</code> - maximum number of concurrently active requests
  <li><code>requestsDurationAve</code> - average duration in milliseconds of request handling
  <li><code>requestsDurationMax</code> - maximum duration in milliseconds of request handling
</ul>
Check the javadoc for the <A HREF="/javadoc/org/mortbay/http/HttpServer.html">org.mortbay.http.HttpServer</A> class for a full list of the statistics available.
</p>

<p/>
<B>JSR77 Statistics</B>
<p>
In addition to the Jetty-specific statistics, since Jetty 5.1 the <A HREF="http://www.jcp.org/en/jsr/detail?id=77">JSR77</A> specification is also supported.
</p>
<p>
To enable JSR77 style statistics, you will need the extra/jsr77 subproject. You can <A HREF="download.html">download</A> it as part of the pre-built full Jetty release, or the pre-built extras package, or build it yourself from source (cd extras/jsr77; ant). 
</p>
<p>
To enable the JSR77 statistics:
<ol>
  <li> add the following lines to your Jetty configuration xml file (copy from the <code>$JETTY_HOME/etc/demo.xml</code> file):
  <pre>
  <code>
  &lt;Set name="WebApplicationConfigurationClassNames"&gt;
    &lt;Array type="java.lang.String"&gt;
      &lt;Item&gt;org.mortbay.jetty.servlet.XMLConfiguration&lt;/Item&gt;
      &lt;Item&gt;org.mortbay.jetty.servlet.JettyWebConfiguration&lt;/Item&gt;
      &lt;Item&gt;org.mortbay.jetty.servlet.jsr77.Configuration&lt;/Item&gt;
    &lt;/Array&gt;
  &lt;/Set&gt;
  </code>
  </pre>
  <li> start Jetty with a command similar to:
<pre>
<code>
  java -DSTART=extra/etc/start-jsr77.config -jar start.jar &lt;name of your config file&gt;
</code>
</pre>
For example, to enable JSR77 statistics for the demo shipped with Jetty:
<pre>
<code>
  java -DSTART=extra/etc/start-jsr77.config -jar start.jar etc/demo-jmx.xml
</code>
</pre>
</ol>

The JMX console can be used to retrieve the statistics. There is one JSR77 object listed for each Servlet in each webapp. JSR77 objects are named according to the JSR77 spec, and will appear like so for Jetty:
<pre>
<code>
  org.mortbay:J2EEServer=null,J2EEApplication=null,J2EEWebModule=<b>&lt;context-name&gt;</b>,j2EEType=Servlet,name=<b>&lt;servlet-name&gt;</b>

  eg
  org.mortbay:J2EEServer=null,J2EEApplication=null,J2EEWebModule=/servlets-examples,j2EEType=Servlet,name=HelloWorldExample 
</code>
</pre>
For more information, refer to the <A HREF="http://www.jcp.org/en/jsr/detail?id=77">JSR77</A> specification.
</p>