In Part 1 of Web Application Performance Testing using Apache JMeter I wrote about how to install Apache JMeter and create a test. In this part I am writing about how to monitor server resources, using the PerfMonAgent Server Agent and the PerfMon Metrics Collector Listener plugin. These are particularly useful when trying to measure the impact over your server during perfomance tests.
PerfMonAgent Server Agent is a tool written in Java, that resides on the target server. It collects statistics about CPU, Memory, Swap, Disks I/O and Networks I/O, supporting a wide range of operating systems. In this example, the target server operating system is CentOS Linux.
Below are the steps to follow for installing and configuring the Server Agent.
NOTES: The process assumes Java and 'wget' are already available. No root privileges are required, except for firewall changes.
- Download and extract the agent:
wget http://jmeter-plugins.googlecode.com/files/ServerAgent-2.2.1.zip unzip ServerAgent-2.2.1.zip
- Start the agent. By default, the listening TCP/UDP ports are 4444:
- If your server is behind a firewall, enable connections on TCP/UDP ports 4444, by appending the following rules to '/etc/sysconfig/iptables':
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4444 -j ACCEPT -A INPUT -m state --state NEW -m udp -p udp --dport 4444 -j ACCEPT
Followed by a firewall restart:
Once the Server Agent is ready, you can configure the PerfMon plugin to connect to it. The following example relies on a test created in the previous part of this article:
- Right click 'HTTP Request', and select 'Add'->'Listener'->'jp@gc – PerfMon Metrics Collector'
- Select the new listener and configure it to keep track of CPU, Memory and Disks I/O reads statistics, by clicking 'Add Row' and changing the 'Host / IP' and 'Port' values to point to the Server Agent IP Address and port; and setting the 'Metric to collect'. Each metric accepts a number of parameters, which can be configured in the last column of each row:
- Start the test, and monitor resource usage:
How to read the above chart: The X Axis specifies the time (since the test started) at which statistics were collected, the Y Axis indicates resource usage, in percentage. In this example, at the the beginning of the test CPU usage was 32%, Disk I/O reads 0% and Memory usage 62%.
With the use of PerfMonAgent Server Agent and PerfMon Metrics Collector you can now monitor the behaviour of your server. Depending on the number of metrics and parameters, these tools can cover: CPU, Memory, Swap, Disks I/O and Networks I/O.