Monitoring JVM metrics via JMX management interface in JMeter
What do we need:
- any java application (doesn’t matter whether it was written in Java/Play/Groovy/JPython etc)
- PerfMon Server Agent
- Apache JMeter wiith jmeter-plugins installed
Once you have plugins installed them in the jMeter’s lib/ext
folder, then:
- On the box you want to monitor, copy templates:
jmxremote.password
&jmxremote.access
from$JAVA_HOME/lib/management
to for example:/srv/play/
- edit them according to your liking
- launch your JAVA application with additional parameters:
java \ -jar your_application.jar \ -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.port=10006 \ -Dcom.sun.management.jmxremote.password.file=/srv/play/jmxremote.password \ -Dcom.sun.management.jmxremote.access.file=/srv/play/jmxremote.access
- start a server-agent (http://jmeter-plugins.org/wiki/PerfMonAgent/
) on the host which JVM metrics you want to monitor using command like:
You can also run it as background process and detach from your session, so it will continue to work even if you disconnect from the server.
cd ${jmeter_folder}/lib/ext/ java \ -jar ./CMDRunner.jar \ --tool PerfMonAgent \ --udp-port 0 \ --tcp-port 7777
cd ${jmeter_folder}/lib/ext/ nohup java \ -jar ./CMDRunner.jar \ --tool PerfMonAgent \ --udp-port 0 \ --tcp-port 7777 &
- add “
PerfMon Metrics Collector
” to your test plan - provide the hostname/IP address of the box running server-agent in the “
Host/IP
” field (don’t forget about the port :) ) - select JMX as the “
Metric to collect
” - double click on “
Metric parameter
” field and then click on the “...
” button to the right - enter all the credentials that the server-agent will use to connect to the local JVM via JMX port. Here’s an example config:
Where role & password are of course defined in the
url=localhost\:10006:user=role:password=password:gc-time
jmxremote.password
&jmxremote.access
files
btw. Here’s an example test plan
with preconfigured PerfMon listener.
If everything was configured properly the you should see something like that on the PerfMon graph: