Difference between revisions of "Profiling OpenKM"
(Created page with ' <source lang="bash"> CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote=true" CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=9090" CATALINA_OPTS="$C…') |
|||
Line 1: | Line 1: | ||
+ | You can profiling local and remote Java applications using [http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/index.html Java VisualVM]. For local application is easy because it detect automatically them and show in the listing. For remote application you need to do a little work. | ||
+ | |||
+ | First of all add this line to '''$TOMCAT_HOME/bin/setenv.sh''' (or '''setenv.bat''' if using Windows) file: | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 5: | Line 8: | ||
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false" | CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false" | ||
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false" | CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false" | ||
− | + | CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=localhost" | |
</source> | </source> | ||
+ | |||
+ | {{Note|The '''java.rmi.server.hostname''' should match the IP of the remote server, so replace '''localhost''' by the right IP.}} | ||
+ | |||
+ | In order to connect to this remote Tomcat instance, go to '''File > Add JMX Connection...''' and fill the hostname and port. In this case the port is 9090 but you can set another one using the '''com.sun.management.jmxremote.port''' property. | ||
+ | |||
+ | More info: | ||
+ | |||
+ | * [https://blogs.oracle.com/nbprofiler/entry/profiling_with_visualvm_part_1 Profiling With VisualVM, Part 1] | ||
+ | * [https://blogs.oracle.com/nbprofiler/entry/profiling_with_visualvm_part_2 Profiling With VisualVM, Part 2] | ||
+ | * [http://hillert.blogspot.com.es/2010/01/remote-profiling-of-jboss-using.html Remote Profiling of JBoss using VisualVM] | ||
== HPROF == | == HPROF == | ||
Java includes HPROF, a profiler which collect application runtime information. HPROF is capable of presenting CPU usage, heap allocation statistics, and monitor contention profiles. | Java includes HPROF, a profiler which collect application runtime information. HPROF is capable of presenting CPU usage, heap allocation statistics, and monitor contention profiles. | ||
− | For example, can collect CPU usage information by sampling threads. Add this line to '''$TOMCAT_HOME/bin/setenv.sh''' file: | + | For example, can collect CPU usage information by sampling threads. Add this line to '''$TOMCAT_HOME/bin/setenv.sh''' (or '''setenv.bat''' if using Windows) file: |
<source lang="bash"> | <source lang="bash"> | ||
− | + | CATALINA_OPTS="$CATALINA_OPTS -agentlib:hprof=cpu=samples" | |
</source> | </source> | ||
Line 24: | Line 37: | ||
* [https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPJMETER HPjmeter] | * [https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPJMETER HPjmeter] | ||
− | + | [[Category: Developer Guide]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 08:39, 20 September 2012
You can profiling local and remote Java applications using Java VisualVM. For local application is easy because it detect automatically them and show in the listing. For remote application you need to do a little work.
First of all add this line to $TOMCAT_HOME/bin/setenv.sh (or setenv.bat if using Windows) file:
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote=true"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=9090"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=localhost"
The java.rmi.server.hostname should match the IP of the remote server, so replace localhost by the right IP. |
In order to connect to this remote Tomcat instance, go to File > Add JMX Connection... and fill the hostname and port. In this case the port is 9090 but you can set another one using the com.sun.management.jmxremote.port property.
More info:
- Profiling With VisualVM, Part 1
- Profiling With VisualVM, Part 2
- Remote Profiling of JBoss using VisualVM
HPROF
Java includes HPROF, a profiler which collect application runtime information. HPROF is capable of presenting CPU usage, heap allocation statistics, and monitor contention profiles.
For example, can collect CPU usage information by sampling threads. Add this line to $TOMCAT_HOME/bin/setenv.sh (or setenv.bat if using Windows) file:
CATALINA_OPTS="$CATALINA_OPTS -agentlib:hprof=cpu=samples"
When Tomcat starts you can see a file called java.hprof.txt. The CPU profiling info will be dumped to this file once Tomcat process is stopped.
More info: