Thanks for visiting the site !!! Visit below intrested Ads to support us if you like the site .Sharing is caring .keep distance and keep safe . Happy Learning ... 😀

Connecting to JBOSS from JVisualVM using JMX

We might have requirement to connect to jboss server and monitor the performance ,heap usage ,threads details ..etc. We can use JMC,JConsole or JVisualVM from Java SDK to connect to JBOSS running on local system or running on a remote system .

Here we will see how we connect to JBOSS using VisualVM with JMX .We will see both standalone and domain mode .

for connecting to JBOSS on a standalone mode we dont require any additional configuration . All we need is jboss up and running , we should have an ManagementRealm ID . create a user if dont have using

Create a Managment user using "EAP_HOME/bin/add-user.sh"

When we start jboss we will use management address

./standalone.sh  -bmanagement 192.168.xx.xx
default 9990 is the admin port 

Copy  jboss-cli-client.jar from "EAP_HOME/bin/client/jboss-cli-client.jar" into windows machine.

Pass jboss-cli-client.jar in classpath: and start VisualVM     $ jvisualvm.exe -cp:a path\to\jboss-cli-client.jar
C:\Program Files\Java\jdk1.8.0_231\bin>jvisualvm.exe -cp:a C:\Users\ameadmin\Downloadsjboss-cli-client.jar

Connection URL looks like this : service:jmx:remote+http://ec2-13-59-7-185.us-east-2.compute.amazonaws.com:9990

Add remote JMX connection . and double click on it

Double click on the connection to open the window .Once connected it will show process id ,hostname ,JAVA version JVM arguments used on the server etc

In the Monitor Tab we can see CPU Heap Meata space Thread details etc . We can also perform GC using this . We will be able to generate Heap Dumps as well.

From the Treads Tab we can see all the thread available on the server . we can also generate thread dump and analyse the threads running on this server .

That all about connecting to JBOSS on standalone mode .

Let us see what we need to do additionally to make same connectivity in JBOSS running on Domain mode .

[root@ip-172-31-14-154 bin]# ./jboss-cli.sh -c --controller=172.31.14.154:9990
[domain@172.31.14.154:9990 /] /socket-binding-group=full-sockets/socket-binding=remoting:add(port=4447)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

[domain@172.31.14.154:9990 /] /profile=full/subsystem=remoting/connector=remoting-connector:add(socket-binding=remoting,security-realm=ApplicationRealm)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

[domain@172.31.14.154:9990 /] /profile=full/subsystem=jmx/remoting-connector=jmx:add(use-management-endpoint=false)
{
    "outcome" => "success",
    "result" => undefined,
    "server-groups" => undefined
}

[domain@172.31.14.154:9990 /] exit
[root@ip-172-31-14-154 bin]# 
1.Create a ApplicationRealm ID using add-user.sh

Without below we should be able to connect to Host controller only on 9990 port .To connect to each individual JVM run below
2. Run below to enable JMX port for each JVM 
/profile=full/subsystem=jmx/remoting-connector=jmx:add(use-management-endpoint=false)
/socket-binding-group=full-sockets/socket-binding=remoting:add(port=4447)
/profile=full/subsystem=remoting/connector=remoting-connector:add(socket-binding=remoting,security-realm=ApplicationRealm)

3.Restart JBoss
[root@ip-172-31-14-154 bin]# ./add-user.sh 

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): b

Enter the details of the new user to add.
Using realm 'ApplicationRealm' as discovered from the existing property files.
Username : appadmin
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password : 
Re-enter Password : 
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: 
About to add user 'appadmin' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'appadmin' to file '/apps/jboss/jboss-eap-7.3/standalone/configuration/application-users.properties'
Added user 'appadmin' to file '/apps/jboss/jboss-eap-7.3/domain/configuration/application-users.properties'
Added user 'appadmin' with groups  to file '/apps/jboss/jboss-eap-7.3/standalone/configuration/application-roles.properties'
Added user 'appadmin' with groups  to file '/apps/jboss/jboss-eap-7.3/domain/configuration/application-roles.properties'
Is this new user going to be used for one AS process to connect to another AS process? 
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? no
[root@ip-172-31-14-154 bin]# 

For domain mode if we directly use 9990 we will connect to Host controller as shown in the below.

To connect to each individual we have to use JMX port . it will be 4447 + off set

service:jmx:remote+http://$HOSTNAME:4447 for first JVM 

Refer below JBOSS documentation for the same to connect on Domain mode for each JVM in 6.4 . on 7.x Remoting port is not required

For a Managed Domain Host

Using the binding the management interface on a managed domain host will only expose the host controller JVM for remote monitoring, and not the individual JBoss EAP servers running on that host.

To configure JBoss EAP to remotely monitor individual servers on a managed domain host, follow the procedure below.

  1. Create a new user in the ApplicationRealm that you will use to connect to the JBoss EAP servers for remote monitoring.
  2. In the management CLI, run the following commands to add a remoting port to the socket binding group, and add remoting to the ApplicationRealm. If necessary, replace the profile name and socket binding group in the following commands with the ones that you are using./profile=full/subsystem=jmx/remoting-connector=jmx:add(use-management-endpoint=false) /socket-binding-group=full-sockets/socket-binding=remoting:add(port=4447) /profile=full/subsystem=remoting/connector=remoting-connector:add(socket-binding=remoting,security-realm=ApplicationRealm)
  3. When starting your JBoss EAP managed domain host, bind one or both of the following interfaces to an IP address that you will use for monitoring.
    • If you want to connect to individual JBoss EAP server JVMs running on your managed domain host, bind the public interface:$ EAP_HOME/bin/domain.sh -b=IP_ADDRESS
    • If you want to connect to the JBoss EAP host controller JVM, also bind the management interface:$ EAP_HOME/bin/domain.sh -bmanagement=IP_ADDRESSWARNINGThis exposes all the JBoss EAP management interfaces, including the management console and management CLI, to the specified network. Ensure that you only bind the management interface to a private network.
  4. Use the following details in your JVM monitoring tool:
    • To connect to individual JBoss EAP server JVMs running on your managed domain host, use the following URI with your ApplicationRealm user name and password that was created earlier.service:jmx:remote://IP_ADDRESS:4447To connect to different JBoss EAP servers on a single host, add the respective server’s port offset value to the above port number.
    • To connect to the JBoss EAP host controller JVM, use the following URI with a management user name and password.service:jmx:remote://IP_ADDRESS:9990

On Jboss 7.X We can directly connect to JVM on domain mode with the below changes

In domain mode, to connect each JVM we can use "jboss.http.port" of each JVM along with "remote+http" protocol. Remoting protocol and port is not required from EAP 7.x
~~~~~~~~~~~~
For ex : (if jboss.http.port is 8080)  

service:jmx:remote+http://<IP>:8080
~~~~~~~~~~~~
Also the configuration for jmx subsystem(JVM profile) should be as following:
~~~~~~~~~~
    <subsystem xmlns="urn:jboss:domain:jmx:1.3">
        <expose-resolved-model/>
        <expose-expression-model/>
        <remoting-connector use-management-endpoint="false"/>  
    </subsystem>
~~~~~~~~~~~

Hope this helps to know the JMX Connectivity ,#JVisualVM, #JMX, #JBOSS, #Monitoring ..etc

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *