JBoss Twiddle utility examples

The below post describes some common usage scenarios of the twiddle JBoss command line utility.

JBoss provides a simple command line tool that allows for interaction with a remote JMX server instance. This tool is called twiddle (for twiddling bits via JMX) and is located in the bin directory of the distribution. Twiddle is a command execution tool, not a general command shell.

Twiddle utility is located in $JBOSS_HOME/bin directory.

You can refer a good read on Twiddle basics from the below link.

http://weblogic-wonders.com/weblogic/2010/12/22/jboss-command-line-utility-twiddle/

Twiddle commands to read the information.

Getting Server Information:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin get "jboss.system:type=ServerInfo"

Getting Global JNDI Information:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin get "jboss:service=JNDIView"

Getitng Jboss Logging Information

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin get "jboss.system:type=Log4jService,service=Logging"

Getting Thread Pool information:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin get "jboss.system:service=ThreadPool"

Twiddle commands to execute operations.

Deploying an application:

twiddle.bat -s jnp://localhost:1099  --user=admin --password=admin invoke "jboss.system:service=MainDeployer" deploy "file:\D:\TestApp.war"

Re-Deploying an application:

twiddle.bat -s jnp://localhost:1099  --user=admin --password=admin invoke "jboss.system:service=MainDeployer" redeploy "file:\D:\TestApp.war"

Un-Deploying an application:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin invoke "jboss.system:service=MainDeployer" undeploy "file:\D:\TestApp.war"

Capturing Thread Dumps:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin  invoke "jboss.system:type=ServerInfo" listThreadDump

List the thread CPU utilization

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin  invoke "jboss.system:type=ServerInfo" listThreadCpuUtilization
NOTE: The output is in table format, you can redirect the output in a html page for better viewing.
G:\jboss-eap-5.1\jboss-as\bin>twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin  invoke "jboss.system:type=ServerInfo" listThreadCpuUtilization>> c:\out.html

Listing the memory pools:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin invoke "jboss.system:type=ServerInfo" listMemoryPools true

Changing logging levels to Debug

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin  invoke "jboss.system:type=Log4jService,service=Logging" setLoggerLevel org.apache debug

Stopping a  DataSource:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin invoke "jboss:service=Hypersonic,database=localDB"  stop

Starting a DataSource:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin invoke "jboss:service=Hypersonic,database=localDB"  start

Stopping the server:

twiddle.bat -s jnp://localhost:1099 --user=admin --password=admin invoke "jboss.system:type=Server" shutdown

Some of the other JMX services that can be used as below.

•             jboss:type=Service,name=SystemProperties     -   enables you to view the system properties

•             jboss:service=JNDIView -                                                 enables you to view the contents of JNDI

•             jboss.system:type=Log4jService,service=Logging -  enable you to change log levels

•             jboss.system:service=ThreadPool -                             enables you to change the thread pool

•             jboss.system:type=Server -                                            provides information about the server

•             jboss.system:type=ServerConfig -                            provides information about the server

•             jboss.system:type=ServerInfo -                                provides information about the server

References:

http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/4.2/html/Server_Configuration_Guide/Connecting_to_the_JMX_Server-Command_Line_Access_to_JMX.html

Cheers,

Wonders Team 🙂

Leave a Reply