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.

While everything is quite obvious with the built-in metrics, custom metrics deserve a more detailed explanation. There are two modes of collecting custom metrics: TAIL and EXEC.

In case of TAIL, you need to specify the name of the file on the server where new values of a metric will appear. The figures will be read from the file at certain time intervals.

EXEC holds the possibilities which are limited solely by your imagination and Bash programming skills, because the source of parameters for this metric is the outcome of executing shell command on the server. For instance, take a look at some PerfMon EXEC examples:

#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.