jmeter/docs/usermanual/listeners.html

793 lines
26 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Content Stylesheet for Site -->
<!-- start the processing -->
<!-- ====================================================================== -->
<!-- Main Page Section -->
<!-- ====================================================================== -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>JMeter - User's Manual: Listeners</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td align="left">
<a href="http://jakarta.apache.org"><img width="505" height="48" src="../images/jakarta-logo.gif" border="0"/></a>
</td>
<td align="right">
<a href="http://jakarta.apache.org/jmeter/"><img width="221" height="102" src="../images/logo.jpg" alt="JMeter" title="JMeter" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade size="1"/>
</td></tr>
<tr>
<!-- LEFT SIDE NAVIGATION -->
<td width="20%" valign="top" nowrap="true">
<p><strong>About</strong></p>
<ul>
<li> <a href="../index.html">Overview</a>
</li>
<li> <a href="../changes.html">Changes</a>
</li>
<li> <a href="../known_bugs.html">Known Bugs</a>
</li>
<li> <a href="../license.html">License</a>
</li>
<li> <a href="http://wiki.apache.org/jakarta-jmeter/JMeterCommitters">Contributors</a>
</li>
</ul>
<p><strong>Download</strong></p>
<ul>
<li> <a href="http://jakarta.apache.org/site/binindex.cgi#jmeter_binaries">Download Binary</a>
</li>
<li> <a href="http://jakarta.apache.org/site/sourceindex.cgi#jmeter_sources">Download Source</a>
</li>
<li> <a href="../nightly.html">Developer (Nightly) Builds</a>
</li>
</ul>
<p><strong>Documentation</strong></p>
<ul>
<li> <a href="../usermanual/index.html">User Manual</a>
</li>
<li> <a href="../api/index.html">Javadocs</a>
</li>
<li> <a href="../localising/index.html">Localisation (Translator's Guide)</a>
</li>
<li> <a href="../building.html">Building JMeter and Add-Ons</a>
</li>
<li> <a href="http://wiki.apache.org/jakarta-jmeter">JMeter Wiki</a>
</li>
<li> <a href="http://wiki.apache.org/jakarta-jmeter/JMeterFAQ">FAQ (Wiki)</a>
</li>
</ul>
<p><strong>Tutorials (PDF format)</strong></p>
<ul>
<li> <a href="../usermanual/jmeter_distributed_testing_step_by_step.pdf">Distributed Testing</a>
</li>
<li> <a href="../usermanual/jmeter_proxy_step_by_step.pdf">Recording Tests</a>
</li>
<li> <a href="../usermanual/junitsampler_tutorial.pdf">JUnit Sampler</a>
</li>
<li> <a href="../usermanual/jmeter_accesslog_sampler_step_by_step.pdf">Access Log Sampler</a>
</li>
<li> <a href="../extending/jmeter_tutorial.pdf">Extending JMeter</a>
</li>
</ul>
<p><strong>Community</strong></p>
<ul>
<li> <a href="http://jakarta.apache.org/site/getinvolved.html">Get Involved</a>
</li>
<li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
</li>
<li> <a href="http://jakarta.apache.org/site/cvsindex.html">SVN Repositories</a>
</li>
</ul>
</td>
<td width="80%" align="left" valign="top">
<table>
<tr>
<td bgcolor="#525D76">
<div align="right"><a href="index.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Index</font></a></div>
</td>
<td bgcolor="#525D76">
<div align="right"><a href="remote-test.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Next</font></a></div>
</td>
<td bgcolor="#525D76">
<div align="right"><a href="build-monitor-test-plan.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Prev</font></a></div>
</td>
</tr>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="intro"><strong>14. Introduction to listeners</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
A listener is a component that shows the results of the
samples. The results can be shown in a tree, tables, graphs or simply written to a log
file. To view the contents of a response from any given sampler, add either of the Listeners "View
Results Tree" or "View Results in table" to a test plan. To view the response time graphically, add
graph results, spline results or distribution graph.
The
<a href="../usermanual/component_reference.html#listeners">listeners</a>
section of the components page has full descriptions of all the listeners.
</p>
<p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
<tr><td>
Different listeners display the response information in different ways.
However, they all write the same raw data to the output file - if one is specified.
</td></tr>
</table></p>
<p >
The "Configure" button can be used to specify which fields to write to the file, and whether to
write it as CSV or XML.
CSV files are much smaller than XML files, so use CSV if you are generating lots of samples.
</p>
<p >
</p>
<p >
If you only wish to record certain samples, add the Listener as a child of the sampler.
Or you can use a Simple Controller to group a set of samplers, and add the Listener to that.
The same filename can be used by multiple samplers - but make sure they all use the same configuration!
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="screencap"><strong>14.1 Screen captures</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
JMeter is capable of saving any listener as a PNG file. To do so, select the
listener in the left panel. Click edit -> Save As Image. A file dialog will
appear. Enter the desired name and save the listener.
</p>
<p><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="../images/screenshots/save_image.png"><br>
<font size="-1"> Figure 1 - Edit -> Save As Image
</font></td></tr></table></p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="batch"><strong>14.2 non-GUI (batch) test runs</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
When running in non-GUI mode, the -l flag can be used to create a top-level listener for the test run.
This is in addition to any Listeners defined in the test plan.
The configuration of this listener is controlled by entries in the file jmeter.properties.
</p>
<p >
This feature can be used to specify different data and log files for each test run, for example:
<pre >
jmeter -n -t testplan.jmx -l testplan_01.jtl -j testplan_01.log
jmeter -n -t testplan.jmx -l testplan_02.jtl -j testplan_02.log
</pre>
</p>
<p >
Note that jmeter logging messages are written to the jmeter.log by default.
This file is recreated each time, so if you want to keep the log files for each run,
you will need to rename it using the -j option as above. The -j option was added in version 2.3.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="resources"><strong>14.3 Resource usage</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
Listeners can be quite resource intensive so use as few as possible.
For minimum resource usage, remove all listeners, and run the test in non-GUI mode with the -l flag to define a single listener.
The result log file can be read back into a Listener after a test has completed.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="csvlogformat"><strong>14.4 CSV Log format</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
The CSV log format depends on which data items are selected in the configuration.
Only the specified data items are recorded in the file.
The order of appearance of columns is fixed, and is as follows:
</p>
<ul >
<li >
timeStamp - in milliseconds since 1/1/1970
</li>
<li >
elapsed - in milliseconds
</li>
<li >
label - sampler label
</li>
<li >
responseCode - e.g. 200, 404
</li>
<li >
responseMessage - e.g. OK
</li>
<li >
threadName
</li>
<li >
dataType - e.g. text
</li>
<li >
success - true or false
</li>
<li >
failureMessage - if any
</li>
<li >
bytes - number of bytes in the sample
</li>
<li >
URL
</li>
<li >
latency - time to first response
</li>
<li >
encoding
</li>
</ul>
<p >
The format of the XML files is as follows:
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="xmlformat2.0"><strong>14.5 XML Log format 2.0</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
The format of the original XML (2.0) is as follows (line breaks will be different):
</p>
<pre >
&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;testResults version="1.2">
&lt;sampleResult timeStamp="1144365463297" dataType="text" threadName="Listen 1-1"
label="HTTP Request" time="1502" responseMessage="OK" responseCode="200" success="true">
&lt;sampleResult timeStamp="1144365464238" dataType="text" threadName="Listen 1-1"
label="http://www.apache.org/style/style.css" time="171" responseMessage="OK" responseCode="200" success="true">
&lt;property xml:space="preserve" name="samplerData">
GET http://www.apache.org/style/style.css
&lt;/property>
&lt;binary>
body, td, th {
font-size: 95%;
font-family: Arial, Geneva, Helvetica, sans-serif;
color: black;
background-color: white;
}
...
&lt;/binary>
&lt;/sampleResult>
&lt;/sampleResult>
...
&lt;/testResults>
</pre>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="xmlformat2.1"><strong>14.6 XML Log format 2.1</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
The format of the updated XML (2.1) is as follows (line breaks will be different):
</p>
<pre >
&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;testResults version="1.2">
-- HTTP Sample, with nested samples
&lt;httpSample t="1392" lt="351" ts="1144371014619" s="true" lb="HTTP Request" rc="200" rm="OK"
tn="Listen 1-1" dt="text" de="iso-8859-1" by="12407">
&lt;httpSample t="170" lt="170" ts="1144371015471" s="true"
lb="http://www.apache.org/style/style.css" rc="200" rm="OK" tn="Listen 1-1" dt="text" de="ISO-8859-1" by="1002">
&lt;responseHeader class="java.lang.String">HTTP/1.1 200 OK
Date: Fri, 07 Apr 2006 00:50:14 GMT
...
Content-Type: text/css
&lt;/responseHeader>
&lt;requestHeader class="java.lang.String">MyHeader: MyValue&lt;/requestHeader>
&lt;responseData class="java.lang.String">body, td, th {
font-size: 95%;
font-family: Arial, Geneva, Helvetica, sans-serif;
color: black;
background-color: white;
}
...
&lt;/responseData>
&lt;cookies class="java.lang.String">&lt;/cookies>
&lt;method class="java.lang.String">GET&lt;/method>
&lt;queryString class="java.lang.String">&lt;/queryString>
&lt;url>http://www.apache.org/style/style.css&lt;/url>
&lt;/httpSample>
&lt;httpSample t="200" lt="180" ts="1144371015641" s="true" lb="http://www.apache.org/images/asf_logo_wide.gif"
rc="200" rm="OK" tn="Listen 1-1" dt="bin" de="ISO-8859-1" by="5866">
&lt;responseHeader class="java.lang.String">HTTP/1.1 200 OK
Date: Fri, 07 Apr 2006 00:50:14 GMT
...
Content-Type: image/gif
&lt;/responseHeader>
&lt;requestHeader class="java.lang.String">MyHeader: MyValue&lt;/requestHeader>
&lt;responseData class="java.lang.String">http://www.apache.org/images/asf_logo_wide.gif&lt;/responseData>
&lt;responseFile class="java.lang.String">Mixed1.html&lt;/responseFile>
&lt;cookies class="java.lang.String">&lt;/cookies>
&lt;method class="java.lang.String">GET&lt;/method>
&lt;queryString class="java.lang.String">&lt;/queryString>
&lt;url>http://www.apache.org/images/asf_logo_wide.gif&lt;/url>
&lt;/httpSample>
&lt;responseHeader class="java.lang.String">HTTP/1.1 200 OK
Date: Fri, 07 Apr 2006 00:50:13 GMT
...
Content-Type: text/html; charset=ISO-8859-1
&lt;/responseHeader>
&lt;requestHeader class="java.lang.String">MyHeader: MyValue&lt;/requestHeader>
&lt;responseData class="java.lang.String"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
...
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
...
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/responseData>
&lt;cookies class="java.lang.String">&lt;/cookies>
&lt;method class="java.lang.String">GET&lt;/method>
&lt;queryString class="java.lang.String">&lt;/queryString>
&lt;url>http://www.apache.org/&lt;/url>
&lt;/httpSample>
-- nonHTTPP Sample
&lt;sample t="0" lt="0" ts="1144372616082" s="true" lb="Example Sampler" rc="200" rm="OK"
tn="Listen 1-1" dt="text" de="ISO-8859-1" by="10">
&lt;responseHeader class="java.lang.String">&lt;/responseHeader>
&lt;requestHeader class="java.lang.String">&lt;/requestHeader>
&lt;responseData class="java.lang.String">Listen 1-1&lt;/responseData>
&lt;responseFile class="java.lang.String">Mixed2.unknown&lt;/responseFile>
&lt;samplerData class="java.lang.String">ssssss&lt;/samplerData>
&lt;/sample>
&lt;/testResults>
</pre>
<p >
Note that the sample node name may be either "sample" or "httpSample".
</p>
<p >
The sample attributes have the following meaning:
</p>
<table>
<tr>
<td bgcolor="#039acc" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Attribute
</font>
</td>
<td bgcolor="#039acc" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Content
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
t
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
elapsed time (ms)
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
lt
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
latency (ms) - not all samplers support this
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
ts
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
timeStamp
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
s
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Success
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
lb
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Label
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
rc
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Response Code
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
rm
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Response Message
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
tn
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Thread Name
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
dt
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Data type
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
de
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Data encoding
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
by
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Bytes
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
ng
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Number of active threads in this group
</font>
</td>
</tr>
<tr>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
na
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan="" valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
Number of active threads for all thread groups
</font>
</td>
</tr>
</table>
<p >
Versions 2.1 and 2.1.1 of JMeter saved the Response Code as "rs", but read it back expecting to find "rc".
This has been corrected so that it is always saved as "rc"; either "rc" or "rs" can be read.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="saving"><strong>14.7 Saving response data</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
As shown above, the response data can be saved in the XML log file if required.
However, this can make the file rather large, and the text has to be encoded so
that it is still valid XML. Also, images cannot be included.
<br >
</br>
Another solution is to use the Post-Processor
<a href="../usermanual/component_reference.html#Save_Responses_to_a_file">Save_Responses_to_a_file</a>
.
This generates a new file for each sample, and saves the file name with the sample.
The file name can then be included in the sample log output.
The data will be retrieved from the file if necessary when the sample log file is reloaded.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="loading"><strong>14.8 Loading (reading) response data</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p >
To view an existing results file, you can use the File "Browse..." button to select a file.
If necessary, just create a dummy testplan with the appropriate Listener in it.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<table>
<tr>
<td bgcolor="#525D76">
<div align="right"><a href="index.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Index</font></a></div>
</td>
<td bgcolor="#525D76">
<div align="right"><a href="remote-test.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Next</font></a></div>
</td>
<td bgcolor="#525D76">
<div align="right"><a href="build-monitor-test-plan.html"><font size=-1 color="#ffffff" face="arial,helvetica,sanserif">Prev</font></a></div>
</td>
</tr>
</table>
<br>
</td>
</tr>
<tr><td colspan="2">
<hr noshade size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 1999-2007, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->