Profiling a tomcat application using VisualVM

I am trying to run visualvm under the username tomcat6, because apparently visualvm can find applications running under its username. Therefore, by default, it only works under my username. I was able to connect visualvm with tomcat6 via jmx, but it lacks the finer granularity of instrumental profiling.

I tried the following to run visualvm under the username tomcat6, but received the following error, which I do not understand.

$ sudo -u tomcat6 jvisualvm
No protocol specified
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
...
+4
source share
4 answers

, , JMX .

visualvm tomcat6 . question , X11 sudo.

DISPLAY XAUTHORITY - sudo -E .

, tomcat6, , CATALINA_TMPDIR /tmp. visualvm

jvisualvm -J-Djava.io.tmpdir="${CATALINA_TMPDIR}"

, yourkit jprofiler java, .

+1

JXM Tomcat, ( ) Tomcat ( ) jvisualvm.

JVM:

-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=<whatever_port_you_want>
-Dcom.sun.management.jmxremote.ssl=false

jvisualvm ( JVM ), β†’ β†’ . . β†’ JMX β†’ β†’ OK

jvisualvm .

, , ( , :

-Dcom.sun.management.jmxremote.password.file=jmxremote.password 
-Dcom.sun.management.jmxremote.access.file=jmxremote.access 

CATALINA_OPTS. :

export CATALINA_OPTS = "$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 "

JMX : https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html

+2

- , JVisualVM . JVisualVM . , . , , ssh.

  • JMX CATALINA_OPTS

    CATALINA_OPTS = "$ CATALINA_OPTS -Dcom.sun.management.jmxremote.port = 13333 -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.ssl = false; export CATALINA_OPTS

  • ssh-

    ssh -D 61444 username@tomcat.server.address

  • JVisualVM,

    "C:\Program Files\Java\jdk1.7.0_79\bin\jvisualvm.exe" -J-Dnetbeans.system_socks_proxy = localhost: 61444 -J-Djava.net.useSystemProxies = true

  • JVisualVM jmxport, - ssh.

    .

0

, , - - - . , VisualVM.

JVM: jstatd JMX. , , JMX, , , jstatd , ..).

JVM Tomcat . 3 :

  • JMX. , .

  • " ", RMI. .

  • (Optional) Arrange secure remote access to the server. The easiest way to do this is to use ssh -Lport:localhost:porta series of arguments -Lto forward multiple ports from your workstation to your server. Compare all the ports that you had to configure in steps # 1 and # 2. If you do not, you need to have access without access to all of the above ports.

  • Restart the JVM and connect to JVisualVM.

0
source

Source: https://habr.com/ru/post/1651727/


All Articles