JMeter Listeners, Part IV: Listeners That Support Scripting and Management
Listeners enable monitoring of JMeter requests, analyze results, and check system health. They aggregate data, process and manipulate info, and enable customization.
Join the DZone community and get the full member experience.Join For Free
Welcome to Part IV of our JMeter listeners series, which is also the final part. In Part I, we explained listeners that have basic displays. In Part II, we went over listeners that aggregate data samples. In Part III, we covered listeners that calculate distribution metrics. This time, we will present listeners that support scripting and enable test and system management.
All listeners can be found by right clicking the test plan Add > Listeners. A JMeter listener will only collect data from JMeter elements at or above its level. For a more detailed explanation, see the first blog post in this series.
Listeners enable monitoring of JMeter requests, analyze results, and check system health. They aggregate data, process and manipulate the information in it, and even enable customization. Read on to learn about the five last listeners we will cover: BeanShell, JSR223, Composite Graph, PerfMon Metrics Collector, and AutoStop.
The BeanShell listener supports Java syntax code and has access to the JMeter runtime variables (vars, CTX, prev, log, props, SampleEvent) and to the methods they support. This enables you to get sample results and compose specific custom reports from them. Results are saved to a file.
In the screenshot below, you can see an example of a BeanShell listener that implements writing aggregated information about response codes that each sample of the script returns to a file. The listener collects all the response codes from the samples in their scope into the Map java object. At the end of the script, in the TearDown thread group, the collected data is written into a file.
The JSR223listener is similar to the BeanShell listener, but it enables selecting between several languages to code the listener functionality.
PerfMon Metrics Collector
Load testing measures not only the behavior of the tested system but also its resource utilization. The PerfMonMetricsCollector listener receives CPU usage, memory consumption, disk and network utilization metrics and provides reports. The data is received from the server agent, which is installed on the servers of the system under the test. The server agent utility collects the resource consumption data of the servers it is installed on and sends them back to the listener. Learn more about the PerfMonMetricsCollector from this article.
One of the most useful JMeter listeners is the AutoStoplistener, which is configured so that the test stops executing if the response time exceeds a certain value or if the error percentage rate is higher than the defined limit. After all, it makes sense to stop the test if the tested service is unresponsive. So, if possible, we recommend you include this listener to the script.
Composite Graph Listener
Finally, there is one listener that can be used to consolidate all the information from other listeners configured in the script and display it on the chart. This is the CompositeGraphlistener, available through JMeter plugins. This listener is useful for finding the cause of bottlenecks or understanding the real capacity of the system under the test. For example, correlating response time charts and resource utilization charts or response time charts and throughput related charts.
Please note that when running your tests in BlazeMeter, you should remove or disable the Listeners, unless you intend to generate extra log files. This is because they consume resources from the machine or engine that is running the test.
That’s it! We’ve covered all the important JMeter listeners. You can also view results, analyze KPIs, and monitor system health through BlazeMeter reports.
Published at DZone with permission of Konsantine Firsanov, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.