Twiddle reference guide

Please note: twiddle is not available any more as default Command Line in JBoss AS 7 and WildFly. If you still need to monitor the MBeans attribute of the application server from the shell, see this article: Monitoring WildFly MBeans from the shell

Twiddle example commands

JBoss provides a simple command line tool that allows for interaction with a remote JMX server instance. This tool is called jboss 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.

The syntax of this tool is: [options] <command> [command_arguments]

Let’s see some practical examples

List of MBeans with twiddle

If you want to see the list of MBeans published simply pass the “-l” argument to serverinfo

twiddle -s localhost serverinfo -l   (for Win Users)

or for Unix machines: -s localhost serverinfo -l

Database Management

How to change the Connection Pool size via twiddle

Supposing you need to change at runtime the size of your datasource named “DefaultDS”, then you can use twiddle command (or modify it manually from the JMX-Console) set jboss.jca:name=DefaultDS,service=ManagedConnectionPool MaxSize 300

This sets the Max ConnectionPool size to 300

How to count the number of Connections available in a Datasource:

(In this example we are checking DefaultDS Datasource) get "jboss.jca:name=DefaultDS,service=ManagedConnectionPool" AvailableConnectionCount

JBoss Management with twiddle

How to shut down JBoss with twiddle: -s hostname invoke jboss.system:type=Server shutdown

How to shutdown JBoss with twiddle using authentication: -s hostname -u admin -p admin invoke jboss.system:type=Server shutdown

JVM Management with twiddle

How to check the amount of free memory available: -s localhost:1099 get "jboss.system:type=ServerInfo" FreeMemory

Take ThreadDump : -s localhost:1099 invoke 'jboss.system:type=ServerInfo' listThreadDump

How to suggest the JVM to run the Garbage collector: invoke jboss.system:type=Server runGarbageCollector

Then you should see from the server log the following message:

13:52:39,281 INFO  [Server] Hinted to the JVM to run garbage collection
13:52:39,281 INFO  [Server] Total/free memory: 170065920/139849848

How to list Thread x CPU Usage: -s localhost:1099 invoke jboss.system:type=ServerInfo listThreadCpuUtilization

Web Applications

How to count active Sessions in a Web application:

twiddle -s localhost get "jboss.web:host=localhost,path=/SampleApp,type=Manager" activeSessions


How to inspect session attributes of a Web application:

First get the list of session ids running: -s localhost invoke "jboss.web:host=localhost,path=/Sample,type=Manager" listSessionIds


Then query for the session attibute: -s localhost invoke  "jboss.web:host=localhost,path=/Sample,type=Manager" 
                          getSessionAttribute  C01C7A10A4209D8A87F6467F5439FEF0 name=JohnSmith

Application Deployment

Deploying an Application : -s localhost:1099 invoke 'jboss.service:MainDeployer' deploy Application.war

Undeploying an Application : -s localhost:1099 invoke 'jboss.service:MainDeployer' undeploy Application.war

Redeploying an Application : -s localhost:1099 invoke 'jboss.service:MainDeployer' redeploy "