Skip to content
David Deuchert edited this page Jul 8, 2019 · 4 revisions

In Progress... Coming Soon

Demo 1 - Bootstrap - Install Perfmon4j Agent into Apache Tomcat

Objective: In this first step we will install the perfmon4j java agent on apache tomcat 9.x. We will then demonstrate the perfmon4j valve and request filter. This filter will add request duration timings to the apache server log.

PreRequisites

The demo is running on Linux Mint 19.1, however perfmon4j is supported on any platform where Java 1.8 or greater can be installed. Linux Mint comes bundled with OpenJDK 11.0.3, however perfmon4j also works with the Oracle JVM.

Although we are using an Apache Tomcat version for this example the perfmon4j agent can be installed in any java application. The perfmon4j servlet "valve" being demonstrated is available for Apache Tomcat, JBoss and Wildfly application servers.

Step 1 - Download and install Apache Tomcat 9.x

Short cut: Download Apache Tomcat 2.0.21 here...

  1. Go to Apache Tomcat download page
  2. Select zip file from the Core Binary Distribution

Step 2 - Install Apache Tomcat 9.x

  1. Unzip and copy the tomcat (once copied rename the "apache-tomcat-9.?.?" folder to "tomcat") install into your home folder.
  2. (Linux only) Marc shell scripts as executable "chmod +x ~/tomcat/bin/*.sh"
  3. In a terminal window execute "./tomcat/bin/catalina.sh run" to start the server
  4. Verify tomcat started successfully by opening a browser and going to http://localhost:8080
  5. In the terminal window press [CTRL-C] to stop tomcat

Step 2 - Download Perfmon4j binary distribution

To obtain the latest javaagent distribution:

Short cut: Download Perfmon4j 1.4.3 Binary here...

  1. Go to the Perfmon4j Github homepage
  2. Scroll toward the bottom of the page where the README.md file is displayed
  3. Under releases select the link for the latest stable release
  4. In JFrog Bintray click on the files link
  5. Select and download the *bin.zip file.

Step 3 - Install the Perfmon4j java agent in tomcat

  1. Open the zip file and copy perfmon4j.jar into "~/tomcat/bin" folder
  2. In a command window execute "export CATALINA_OPTS=-javaagent:./bin/perfmon4j.jar"
  3. Restart tomcat with "./tomcat/bin/catalina.sh run"
  4. You should see the Perfmon4j banner displayed

After this step we have installed the perfmon4j agent, however it is not yet "doing" anything useful. In this next step we will install a servlet valve to print out detailed information about incoming web requests.

Step 4 - Install the perfmon4j servlet valve.

  1. If tomcat is running shutdown with [CTRL-C]
  2. In a command window execute "export CATALINA_OPTS=-javaagent:./bin/perfmon4j.jar=-eVALVE,-f./conf/perfmonconfig.xml"
  3. In a text editor create a file "~/tomcat/conf/perfmonconfig.xml" with the following contents:
<Perfmon4JConfig enabled='true'>
	<boot>
		<servletValve outputRequestAndDuration='true' />
	</boot>
</Perfmon4JConfig>