Monitoring Server Performance: Jmeter's Essential Role

how to monitor server performance through jmeter

Performance testing is crucial to identify underlying issues and analyse test results. JMeter is a performance monitoring tool that can be used to monitor server health and performance during load tests. It provides end-to-end performance statistics in real-time but does not reveal how the backend is performing. By monitoring server performance, one can identify when the server is overloaded and troubleshoot accordingly. This can be done by setting up the PerfMon Metrics Collector and Server Agent, which collects metrics on server health and sends them back to JMeter for analysis. Additionally, JMeter plugins allow for the monitoring of CPU, memory, disk and network usage.

Characteristics Values
Number of requests per second Depends on the server
Speed of data transfer Depends on the server
Amount of transferred data Depends on the server
CPU load Depends on the server
Number of files opened by a particular process Depends on the server
Memory Depends on the server
Swap Depends on the server
Disk I/O Depends on the server
Network I/O Depends on the server
JMX Depends on the server

shundigital

How to monitor server health during a JMeter load test

To monitor server health during a JMeter load test, you can use the PerfMon plugin, which consists of two parts: the Server Agent and the Metrics Collector Listener.

Setting up the Server Agent:

First, ensure that Java is installed on your server. Then, follow these steps:

  • Download the Server Agent to the server where the application is deployed.
  • Unzip the downloaded folder.
  • Navigate to the unzipped folder and grant read, write, and execute permissions to startAgent.sh.
  • Start the server agent.

Note: The server agent will collect metrics and send them to JMeter via UDP or TCP protocol, with the default port being 4444.

Setting up the Metrics Collector Listener:

To capture metrics such as CPU and memory utilization:

  • Ensure Java is installed, and the JMeter application is downloaded and configured.
  • Add the PerfMon Metrics Collector listener to the configured thread groups.
  • Configure the IP and hostname of the server to be monitored.
  • Start the test. The PerfMon Metrics Collector will begin capturing the configured resources.

Viewing System Health:

  • Go to the "Application under Test" side and open the "Performance" tab in the Task Manager, switching to the "Ethernet" view.
  • In JMeter, provide the IP address of the machine with the test application, the port the PerfMon Server Agent is listening to, and the metric you want to monitor (e.g., Network I/O).
  • Start the test and observe the charts.

Custom Metrics:

For metrics not included in the SIGAR (System Information Gatherer and Reporter) API, you can use the TAIL or EXEC metrics:

  • TAIL: Reads the last line of a single-column file of plain numeric values and plots the results in a chart.
  • EXEC: Executes an arbitrary command or program and sends the results back to the JMeter Metrics Collector. Ensure the output is a single numeric value.

Alternative Approach:

The SSHMon plugin is another way to collect server metrics without installing an agent. It connects to the server via SSH and executes commands to retrieve data. This approach may be more flexible for Linux OS, as it has more monitoring utilities than Windows.

shundigital

Installing the PerfMon Metrics Collector

The PerfMon Metrics Collector can be installed using the JMeter Plugins Manager. Look for the "PerfMon (Servers Performance Monitoring)" plugin.

Firstly, download the PerfMon Server Agent from the JMeter Plugins download page. You will need to download it separately—it is called ServerAgent-x.x.x.zip. The Server Agent is a Java command-line application, so you will need the Java Runtime Environment (JRE). It is recommended to use the same 64-bit Server JRE or JDK (Java SE Development Kit) of the latest available Java version for JMeter. You can download the JRE/JDK from Oracle's Java download page.

Once downloaded, unpack the Server Agent. You should see the following structure:

  • Folder containing dependency libraries (mostly SIGAR)
  • The same .jar file which comes with JMeter Plugins (this lives under the /lib/ext folder of the JMeter installation). This launches the Server Agent
  • The Apache License file
  • Main Server Agent library
  • Server Agent Launch script for Windows
  • Server Agent Launch script for Linux/MacOSX/Unix

To start the Server Agent, use the startAgent.x script. You should then see three lines, indicating that the Server Agent is up and running and listening for TCP and UDP connections on port 4444 (the default port).

Check the connectivity from the JMeter host before running any load tests. You can do this by sending a "test" message via telnet or netcat. You should be able to view three steps:

  • The connection to the Server Agent
  • The "test" command being sent
  • The "shutdown" command being sent

If you can see a similar output, you are all set. If not, you will need to troubleshoot networking issues. The problem may be that port 4444 is blocked by a firewall.

To change the port, use this command: .\startAgent.bat –-tcp-port 3450.

PerfMon Metrics Collector Setup

Open the JMeter test plan you will be executing. Open the Plugins Manager to install the PerfMon Metrics Collector listener. Click on Available Plugins and search for PerfMon to install the listener.

Once the plugin is installed, restart JMeter and add the jp@gc – PerfMon Metrics Collector by right-clicking on Thread Group > Add > Listener > jp@gc – PerfMon Metrics Collector. This will add a listener to your test plan.

Click on the Add Row button to add the Host, Port, and Metric to collect with the default values. You can add multiple metrics by clicking on the Add Row button.

After adding the listener, validate your test plan by right-clicking on Thread Group > Validate. This will send one iteration of your requests in the test plan.

shundigital

Configuring the PerfMon Metrics Collector

The PerfMon Metrics Collector can be installed using the JMeter Plugins Manager. Look for the "PerfMon (Servers Performance Monitoring)" plugin.

To configure the PerfMon Metrics Collector, follow these steps:

  • In the PerfMon Metrics Collector listener, click the “Add” button to add a server.
  • Enter the server details, including the hostname/IP and port, for the machine where you want to collect performance metrics.
  • Select the checkboxes for the metrics you want to collect, such as CPU, Memory, Disk, and Network.
  • Configure the polling interval and other options according to your requirements.

You can also edit properties in jmeter.properties to control the plugin behaviour:

  • Jmeter.sshmon.knownHosts: Specifies the filename of a known_hosts file containing public keys of trusted remote servers (in OpenSSH format). If not set, no validation will be performed.
  • Jmeter.sshmon.interval: Defines the metrics collection interval in milliseconds (default is 1 second).
  • Jmeter.sshmon.forceOutputFile: Enables JMeter to write metrics to a CSV file in the current directory if no filename is specified (default is false).

By following these steps, you can configure the PerfMon Metrics Collector to monitor the performance of your servers during load testing with JMeter.

shundigital

Collecting and viewing server health metrics

JMeter cannot retrieve server metrics by default, except for Tomcat ones. However, there is a plugin available for monitoring server health called PerfMon Server Agent. This plugin supports the collection of over 75 system metrics, including CPU, Memory, Swap, Disks I/O and Networks I/O on almost all platforms.

To install the Server Agent:

  • Download the Server Agent zip file.
  • Unzip the file and place the folder on your server (ensure JRE is installed and configured).
  • From the Server Agent folder, execute startAgent.bat (for Windows) or startAgent.sh (for Linux/macOS/Unix). Keep this file running.

To setup and run a test to monitor server health, you will need the PerfMon Metrics Collector listener in your JMeter instance.

To do this:

  • Download the StandardSet plugin from the Jmeter-Plugins site.
  • Extract the contents of the zip file in your JMeter's root directory.
  • Start JMeter and add your test plan.
  • Add the PerfMon Metrics Collector listener to your test plan.
  • Add the IP address of your servers, along with the Port Number (the default is 4444) and select the metrics to collect.
  • Save your test plan and execute it.

The server health metrics will then be displayed in a chart in the PerfMon Metrics Collector listener.

It is also possible to monitor server performance using JMeter's SSHMon Listener. This allows you to connect to the server via SSH and execute the necessary command to retrieve the data.

To add the SSHMon Listener to your test scenario:

  • Right-click on Test Plan or Thread Group -> Add -> Listeners -> SSHMon Samples Collector.
  • Configure the server metrics in the table. This includes the Label (name of the metric), Host/Port, Username/Password, Private Key (PEM), Command and Delta.

To collect standard metrics like Network, CPU and Disk Usage, you can use Perfmon. With SSHMon, you will need to know which command to execute to get the right value.

For example, to get CPU usage on a Windows system, you can use the Get-Counter command in PowerShell. To get additional metrics, change the name given in the inverted commas.

For Linux systems, you can use utilities like vmstat, iostat, mpstat, and sar to perform monitoring. For instance, the sar utility can provide performance information about the processor, memory, Disk I/O and network in real time.

It is important to note that JMeter is primarily used for load testing, and monitoring server health is just one aspect of its capabilities.

shundigital

Collecting custom metrics

Using PerfMon Metrics Collector:

PerfMon, a JMeter plugin, offers a way to collect metrics on your server health. It consists of two parts: the Metrics Collector Listener and the Server Agent. The Server Agent collects metrics and sends them back to JMeter via TCP or UDP. You can then view these metrics through the Metrics Collector Listener. To install the Server Agent, download it separately and ensure you have the Java Runtime Environment (JRE). You can then extract and run the appropriate startAgent script for your operating system.

Using TAIL Metric:

The TAIL metric offers functionality similar to the Unix tail command. It reads the last line of a given file and plots the results in a chart. The file should be a single column set of plain numeric values, with each value on its own line. You can configure the filename and chart label to your requirements. Once added, the remote Server Agent will read the specified file and send the values back to the PerfMon Metrics Collector for visualisation.

Using EXEC Metric:

The EXEC metric allows for the execution of arbitrary commands or programs, sending the results back to the JMeter Metrics Collector. The output should be a single numeric value so it can be represented in a chart. The configuration is straightforward, where you enter the command you want to monitor into the Metric Parameter. The format should be as follows: "command:first argument:second argument:etc". Ensure that any colons in the command path or argument are escaped with a backslash. The EXEC metric provides a lot of flexibility but also opens up a potential security risk, so be cautious when using it.

Using JMeter Dashboard Report:

JMeter supports dashboard report generation, providing graphs and statistics from a test plan. The dashboard generator is a modular extension that processes samples from CSV files to generate HTML files containing graph views. This report provides various metrics, including APDEX tables, request summary graphs, statistics tables, error tables, and more. You can configure and customise these reports using JMeter properties.

Using Backend Listener:

JMeter allows you to get real-time results sent to a backend through the Backend Listener. You can use different backend clients, such as GraphiteBackendListenerClient or InfluxDBBackendListenerClient, to send metrics to a Graphite or InfluxDB backend, respectively. This enables you to compare load tests, add annotations to graphs, and store monitoring data. JMeter configuration involves adding a BackendListener using the appropriate backend client.

Frequently asked questions

Written by
Reviewed by
Share this post
Print
Did this article help you?

Leave a comment