Command-line JMX Client

A command-line JMX client (RMI to a remote JMX Agent).

Usage

To use, do the following to obtain usage: % java -jar cmdline-jmxclient.jar:

Usage: java -jar cmdline-jmxclient.jar USER:PASS HOST:PORT [BEAN] [COMMAND]
Options:
 USER:PASS Username and password. Required. If none, pass '-'.
           E.g. 'controlRole:secret'
 HOST:PORT Hostname and port to connect to. Required. E.g. localhost:8081.
           Lists registered beans if only USER:PASS and this argument.
 BEAN      Optional target bean name. If present we list available operations           and attributes.
 COMMAND   Optional operation to run or attribute to fetch. If none supplied,           all operations and attributes are listed. Attributes begin with a
           capital letter: e.g. 'Status' or 'Started'. Operations do not.
           Operations can take arguments by adding an '=' followed by
           comma-delimited params. Pass multiple attributes/operations to run           more than one per invocation. Use commands 'create' and 'destroy'
           to instantiate and unregister beans ('create' takes name of class).
           Pass 'Attributes' to get listing of all attributes and and their
           values.
Requirements:
 JDK1.5.0. If connecting to a SUN 1.5.0 JDK JMX Agent, remote side must be
 started with system properties such as the following:
     -Dcom.sun.management.jmxremote.port=PORT
     -Dcom.sun.management.jmxremote.authenticate=false
     -Dcom.sun.management.jmxremote.ssl=false
 The above will start the remote server with no password. See
 http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html for more on
 'Monitoring and Management via JMX'.
Client Use Examples:
 To list MBeans on a non-password protected remote agent:
     % java -jar cmdline-jmxclient-X.X.jar - localhost:8081 \
         org.archive.crawler:name=Heritrix,type=Service
 To list attributes and attributes of the Heritrix MBean:
     % java -jar cmdline-jmxclient-X.X.jar - localhost:8081 \
         org.archive.crawler:name=Heritrix,type=Service \
         schedule=http://www.archive.org
 To set set logging level to FINE on a password protected JVM:
     % java -jar cmdline-jmxclient-X.X.jar controlRole:secret localhost:8081 \
         java.util.logging:type=Logging \
         setLoggerLevel=org.archive.crawler.Heritrix,FINE

This cmdline-jmxclient can be used to connect to the SUN JVM JDK 1.5.0 JMX Agent to set logging levels remotely and to get information on the running JVM. It can also be used to remotely control Heritrix (Heritrix starts the SUN JVM JDK 1.5.0 JMX Agent when its run under SUN JDK 1.5.0 and then attaches Management Beans for control and monitoring). This command-client can probably be gotten to talk to other JMX Agents but its only been tried against the JDK JMX Agent.

Links

Other JMX Cmdline Clients

  • See on this page, JMX HOWTO. Depends on MX4J. Puts up a basic shell for interaction with MBeans.
  • twiddle, bundled with JBOSS. Depends on JBOSS

Limitations

  • Not only does the designated remote server port need to be accessible to the client -- i.e. no firewall blocking -- but, because the communication uses RMI and RMI works by returning to the client an arbitrarily chosen port for it to use in subsequent communications, unless some kind of tunnelling is setup, you'll need to have arbitrary port access to the server machine from the client (IA Peoples: Run from homeserver).
  • Doesn't (yet) return info on notifications and constructors available.
  • Not yet tested over SSL.