Monitoring WildFly MBeans from the shell

WildFly ships with a powerful Command Line Interface which allows a full management control of the server. If you are using MBeans to capture relevant attributes of the server many options are still available. Besides the UI views which are available in jconsole or jvisualvm, you can use the plain command line to include it as part of some bash scripts.

Use hawtio REST API

The recommended option for monitoring WildFly MBeans is via hawtio REST API. In this tutorial you can learn more about installing hawtio on JBoss EAP /WildFly: Hawtio quickstart tutorial

Once installed hawtio you can by default you can connect on http;//localhost:8778/jolokia to access the jolokia REST API. For example, if you want to capture the server version, you could use:

$ curl http://localhost:8080/hawtio/jolokia/read/jboss.as:management-root=server/productVersion

There is no need to search for the correct MBean structure. By clicking on each attribute, you will be able to pickup the correct REST URL:

jboss monitoring

 Use twiddle

Yes, although disappeared since JBoss AS 7, there is also a project named twiddle available at https://github.com/swesource/twiddle-standalone which can be used to connect to WildFly and query Mbeans. Installing it is pretty simple, unpack the jar file, then set the JBOSS_HOME:

$ export JBOSS_HOME=/home/jboss/wildfly-10.1.0.Final/

In order to use it, you have to point to the correct protocol, which is jmx:remoting-jmx for JBoss AS 7 and EAP 6. On the other hand, if you are using WildFly, then you have to go through the jmx-http protocol. Here are some examples:

JBoss EAP 6 / AS 7

$ ./twiddle.sh -s service:jmx:remoting-jmx://127.0.0.1:9999 get jboss.as:management-root=server

WildFly

$ ./twiddle.sh -s service:jmx:remote+http://localhost:9990 get jboss.as:management-root=server

 

 

Found the article helpful? if so please follow us on Socials