JMeter: Monitoring the Load of the Tested Server

During a load testing, it is necessary to remember that apart from retrieving external metrics (the number of requests per second, data transfer speed, data volume, etc.), it is also important to collect the metrics of the tested server load. This may include anything from CPU load to the number of files opened by a specific process.

Out of the box, JMeter can't monitor the remote server load. This can be done with the help of PerfMon Metrics Collector plugin, which is included into the standard set of JMeter's plugins. PerfMon Metrics Collector can gather the following load metrics:

  • CPU,
  • Memory,
  • Disks I/O,
  • Networks I/O,
  • some variables inside Java Virtual Machine (through JMX),
  • TCP protocol metrics,
  • swap file,
  • custom metrics.

The built-in metrics are straightforward, but custom metrics require further explanation. There are two methods for collecting custom metrics: TAIL and EXEC.

With TAIL, you must identify the file name on the server where the metric's new values will be stored. The values are then read from the file at specific intervals.

On the other hand, EXEC offers limitless possibilities that are dependent on your Bash programming abilities and creativity. This method retrieves parameters for the metric from the results of executing a shell command on the server. Examples of PerfMon EXEC include:

#Example1: Monitoring Linux cached memory size, used free utility output:
/bin/sh:-c:free | grep Mem | awk '{print $7}'

#Example2: Monitoring MySQL select query count:
/bin/sh:-c:echo "show global status like 'Com_select'" | mysql -u root | awk '$1 =="Com_select" {print $2}'

#Example3: Monitoring PostgreSQL CPU usage in percents:
/bin/sh:-c:ps aux | grep "postgres" | grep -v "grep" | grep "puser" | awk 'BEGIN  {a = $3; c += a} END {print c}'

Monitoring the load of the tested server with the help of PerfMon will allow you to spot bottlenecks in server configuration or settings and will help you to evaluate the aptness of the server for dealing with certain load.