Using VisualVM with WildFly: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(33 intermediate revisions by the same user not shown)
Line 11: Line 11:
=Overview=
=Overview=


A JBoss instance can be configured to allow a ''direct'' VisualVM remote JMX connection into it. This article explains how to configure JBoss and VisualVM in order to achieve this.
A JBoss instance can be configured to allow VisualVM to connect to it and pull JMX metrics. This article explains how to configure JBoss and VisualVM for that.


=JBoss Configuration=
=JBoss Configuration=


JBoss 7 exposes a [[JSR 160 Java Management Extensions (JMX) Remote API|JSR-160 Java Management Extensions (JMX) Remote API]] compliant [[JMXConnector]], which can be used by VisualVM to connect remotely and access the JBoss' JMX bus. The native management access is configured in the standard JBoss configuration files ([[standalone.xml]] or [[domain.xml]]).
The JBoss instance configuration required to allow a VisualVM connection is described in the following articles:
The users that are authorized to connect must be part of the “ManagementRealm” JBoss security realm.
 
For more details on how to configure the native management interface see:
 
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[JBoss 7 Management Configuration#TheNativeManagementInterface]]
</blockquote>
 
The users that are allowed to use the native management interface must be added to the "ManagementRealm". For more details on how to configure security, see:


<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[[JBoss 7 Security Realm#ManagementRealm]]
: [[JMX_Access_to_Standalone_EAP_6#Server_Endpoint|Standalone EAP 6 - Server Endpoint]]
: [[JMX Access to EAP 6 Host Controller#Server_Endpoint|EAP 6 Host Controller - Server Endpoint]]
: [[JMX Access to Domain Mode EAP 6 Server Node#Server_Endpoint|Domain Mode EAP 6 Server Node - Server Endpoint]]
: [[JMX Access To Standalone EAP 7#Server_Endpoint|Standalone EAP 7 - Server Endpoint]]
: [[JMX Access to EAP 7 Host Controller#Server_Endpoint|EAP 7 Host Controller - Server Endpoint]]
: [[JMX Access to Domain Mode EAP 7 Server Node#Server_Endpoint|Domain Mode EAP 7 Server Node - Server Endpoint]]
</blockquote>
</blockquote>


Use [[add-user.sh]] to actually add the users to the ManagementRealm.
=Configuring VisualVM to Connect over JMX to a JBoss Instance=


=Visual VM Configuration=
==VisualVM Classpath and Startup Options==


==Startup Script==
In order to be able to access the JBoss native management interface directly, Visual VM needs specific JBoss client libraries in its classpath. It also needs the <tt>-Dmodule.path</tt> system property, as specified below.


In order to be able to access the JBoss 7 native management interface directly, Visual VM needs specific JBoss 7 libraries in its classpath. It's best if a specialized script is created and used to start it. The examples presented below use only the specific JARs needed by the remote JMX access. This also works:
===Linux and Mac===


<pre>
<pre>
$JBOSS_HOME/bin/client/jboss-client.jar
jvisualvm \
  -cp:a ${JBOSS_HOME}/bin/client/jboss-cli-client.jar \
  -J-Dmodule.path=${JBOSS_HOME}/modules
</pre>
</pre>
===Linux & Mac===


===Windows===
===Windows===
Line 55: Line 51:
"%JAVA_HOME%\bin\jvisualvm.exe" -cp:a %JBOSS_MODULES%\org\jboss\remoting3\remoting-jmx\main\remoting-jmx-1.0.2.Final.jar;%JBOSS_MODULES%\org\jboss\remoting3\main\jboss-remoting-3.2.3.GA.jar;%JBOSS_MODULES%\org\jboss\logging\main\jboss-logging-3.1.0.GA.jar;%JBOSS_MODULES%\org\jboss\xnio\main\xnio-api-3.0.3.GA.jar;%JBOSS_MODULES%\org\jboss\xnio\nio\main\xnio-nio-3.0.3.GA.jar;%JBOSS_MODULES%\org\jboss\sasl\main\jboss-sasl-1.0.0.Final.jar;%JBOSS_MODULES%\org\jboss\marshalling\main\jboss-marshalling-1.3.11.GA.jar;%JBOSS_MODULES%\org\jboss\marshalling\river\main\jboss-marshalling-river-1.3.11.GA.jar
"%JAVA_HOME%\bin\jvisualvm.exe" -cp:a %JBOSS_MODULES%\org\jboss\remoting3\remoting-jmx\main\remoting-jmx-1.0.2.Final.jar;%JBOSS_MODULES%\org\jboss\remoting3\main\jboss-remoting-3.2.3.GA.jar;%JBOSS_MODULES%\org\jboss\logging\main\jboss-logging-3.1.0.GA.jar;%JBOSS_MODULES%\org\jboss\xnio\main\xnio-api-3.0.3.GA.jar;%JBOSS_MODULES%\org\jboss\xnio\nio\main\xnio-nio-3.0.3.GA.jar;%JBOSS_MODULES%\org\jboss\sasl\main\jboss-sasl-1.0.0.Final.jar;%JBOSS_MODULES%\org\jboss\marshalling\main\jboss-marshalling-1.3.11.GA.jar;%JBOSS_MODULES%\org\jboss\marshalling\river\main\jboss-marshalling-river-1.3.11.GA.jar
</pre>
</pre>
<font color=red>TODO: to simplify.</font>


==Configuring Access to the JBoss Instance==
==Configuring Access to the JBoss Instance==
===Explicit JMX Remote Connection===


Start VisualVM with the script describe above.
Start VisualVM with the script describe above.
Line 62: Line 62:
Then go to "Application" left tab, right click on "Remote" and "Add Remote Host...".
Then go to "Application" left tab, right click on "Remote" and "Add Remote Host...".


Use the remote host IP address (or host name).
Use the remote host IP address (or host name). Note that the host name must be resolvable locally, otherwise the UI will complain.


Right click on the newly added "remote host" and "Add JMX Connection..."
Right-click on the newly added "remote host" and "Add JMX Connection..."


As "Connection" use:
If the JVM to be connected to over JMX runs on the local host, right click on the "Local" node, then right-click and then "Add JMX Connection"


<pre>
As "Connection", depending on the JBoss version you're connecting to, use the following URLs:
service:jmx:remoting-jmx://<your-server-ip-address>:9999
 
</pre>
* [[JMX_Access_to_Standalone_EAP_6#URL|For Standalone EAP 6]]
* [[JMX_Access_to_EAP_6_Host_Controller#URL|For EAP 6 Host Controller]]
* [[JMX_Access_to_Domain_Mode_EAP_6_Server_Node#URL|For EAP 6 Domain Mode Server Node]]
* [[JMX Access To Standalone EAP 7#URL|For Standalone EAP 7]]
* [[JMX_Access_to_EAP_7_Host_Controller#URL|For EAP 7 Host Controller]]
* [[JMX_Access_to_Domain_Mode_EAP_7_Server_Node#URL|For EAP 7 Domain Mode Server Node]]


replacing <your-server-ip-address> with the actual address.
replacing the corresponding *host placeholder with the actual address.


Select "Use Security Credentials"
Select "Use Security Credentials"
Line 81: Line 86:


and then check "Do not require SSL connection".
and then check "Do not require SSL connection".
The configuration is persisted across VisualVM restarts. For more details see [[#VIsualVM_Configuration_Persistence|VisuaVM Configuration Persistence]].
===Explicit Local Remote Connection===
If VisualVM and the target JBoss instance are located on the same host, you will need to use the Local connection, but otherwise, the details are similar to the ones described above.
===Alternative JMX Connection using Attach API===
Install the [[#JMX_MBean_Access|VisualVM-MBeans]] as described below.
If the JBoss instance we want to inspect runs on the local host, it will be available under the "Local" node:
Double click on it, the MBean access should be available in the MBeans tab:
[[Image:VisualVMMBeans.png]]


==JMX MBean Access==
==JMX MBean Access==
Line 89: Line 110:


Tools -> Plugins -> Available Plugins -> Check the plugin to be installed -> Install.
Tools -> Plugins -> Available Plugins -> Check the plugin to be installed -> Install.
==VIsualVM Configuration Persistence==
The JMX connections defined as described [[#Configuring_Access_to_the_JBoss_Instance|above]] survive a VisualVM instance restart.

Latest revision as of 17:14, 27 April 2017

External

Internal

Overview

A JBoss instance can be configured to allow VisualVM to connect to it and pull JMX metrics. This article explains how to configure JBoss and VisualVM for that.

JBoss Configuration

The JBoss instance configuration required to allow a VisualVM connection is described in the following articles:

Standalone EAP 6 - Server Endpoint
EAP 6 Host Controller - Server Endpoint
Domain Mode EAP 6 Server Node - Server Endpoint
Standalone EAP 7 - Server Endpoint
EAP 7 Host Controller - Server Endpoint
Domain Mode EAP 7 Server Node - Server Endpoint

Configuring VisualVM to Connect over JMX to a JBoss Instance

VisualVM Classpath and Startup Options

In order to be able to access the JBoss native management interface directly, Visual VM needs specific JBoss client libraries in its classpath. It also needs the -Dmodule.path system property, as specified below.

Linux and Mac

jvisualvm \
  -cp:a ${JBOSS_HOME}/bin/client/jboss-cli-client.jar \
  -J-Dmodule.path=${JBOSS_HOME}/modules

Windows

@echo off

set JBOSS_HOME=C:\ovidiu\jboss-as-7.1.1.Final
set JBOSS_MODULES=%JBOSS_HOME%\modules
set JAVA_HOME="C:\Program Files\Java\jdk1.7.0_79"

"%JAVA_HOME%\bin\jvisualvm.exe" -cp:a %JBOSS_MODULES%\org\jboss\remoting3\remoting-jmx\main\remoting-jmx-1.0.2.Final.jar;%JBOSS_MODULES%\org\jboss\remoting3\main\jboss-remoting-3.2.3.GA.jar;%JBOSS_MODULES%\org\jboss\logging\main\jboss-logging-3.1.0.GA.jar;%JBOSS_MODULES%\org\jboss\xnio\main\xnio-api-3.0.3.GA.jar;%JBOSS_MODULES%\org\jboss\xnio\nio\main\xnio-nio-3.0.3.GA.jar;%JBOSS_MODULES%\org\jboss\sasl\main\jboss-sasl-1.0.0.Final.jar;%JBOSS_MODULES%\org\jboss\marshalling\main\jboss-marshalling-1.3.11.GA.jar;%JBOSS_MODULES%\org\jboss\marshalling\river\main\jboss-marshalling-river-1.3.11.GA.jar

TODO: to simplify.

Configuring Access to the JBoss Instance

Explicit JMX Remote Connection

Start VisualVM with the script describe above.

Then go to "Application" left tab, right click on "Remote" and "Add Remote Host...".

Use the remote host IP address (or host name). Note that the host name must be resolvable locally, otherwise the UI will complain.

Right-click on the newly added "remote host" and "Add JMX Connection..."

If the JVM to be connected to over JMX runs on the local host, right click on the "Local" node, then right-click and then "Add JMX Connection"

As "Connection", depending on the JBoss version you're connecting to, use the following URLs:

replacing the corresponding *host placeholder with the actual address.

Select "Use Security Credentials"

Use an user name and a password that was previously added to the "ManagementRealm" of the application server.

Optionally "Save security credentials"

and then check "Do not require SSL connection".

The configuration is persisted across VisualVM restarts. For more details see VisuaVM Configuration Persistence.

Explicit Local Remote Connection

If VisualVM and the target JBoss instance are located on the same host, you will need to use the Local connection, but otherwise, the details are similar to the ones described above.

Alternative JMX Connection using Attach API

Install the VisualVM-MBeans as described below.

If the JBoss instance we want to inspect runs on the local host, it will be available under the "Local" node:

Double click on it, the MBean access should be available in the MBeans tab:

VisualVMMBeans.png

JMX MBean Access

In order to access JMX interfaces of MBeans, you will need to install the "VisualVM-MBeans" VisualVM plugin.

A plugin can be installed as follows:

Tools -> Plugins -> Available Plugins -> Check the plugin to be installed -> Install.

VIsualVM Configuration Persistence

The JMX connections defined as described above survive a VisualVM instance restart.