views:

2634

answers:

3

I know we can use tools like JProfiler etc. Is there any tutorial on how to configure it to display the memory usage just by remote monitoring?

Any idea?

+3  A: 

you have VisualGC, it's not very advanced but you can see the memory usage of your application (garbage,old, perm etc...)

http://java.sun.com/performance/jvmstat/visualgc.html

to resume : you launch a daemon monitoring on the remote machine (http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstatd.html, see the security parapraph)

JAVA_HOME/bin/jstatd -J-Djava.security.policy=jstatd.all.policy

with a file here called jstatd.all.policy containing :

    grant codebase "file:${java.home}/../lib/tools.jar" {   
permission java.security.AllPermission;
};

on the remote machine you got the pid of your application to debug with the jps tool :

http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jps.html#jps

finally on your local machine you launch the visualgc :

visualgc the_pid@remote_machine_address
Matthieu
+2  A: 

you can change to VM params of your java application to allow remote profiling something like -agentlib:jprofilerti=port=25000

general explanation for jprolifer

http://resources.ej-technologies.com/jprofiler/help/doc/

example is http://profiler.netbeans.org/docs/help/5.5/attach.html#direct_attach vor netbeans

or

http://plugins.intellij.net/plugin/?id=253 for my favorite IDE Intellij

Peter
+2  A: 

I usually use YourKit which is an excellent application (license needed).

In your webservers startup/shutdown script (catalina.sh for tomcat) put in:

JAVA_OPTS="-Djava.awt.headless=true -agentlib:yjpagent -Xrunyjpagent:sessionname=Tomcat"

You'll need YourKit already downloaded and added to your library path (I do this in catalina.sh as well):

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/yourkit/yjp-6.0.16/bin/linux-x86-32

You can then launch the YourKit client on your local desktop and remotely connect.

Joe Wright