Collect JMX beans into a tab-delimited file using jmxtrans

How to collect?

JMX metrics can be collected with the jmxtrans tool:

usage: java -jar jmxtrans-all.jar
 -a,--additionalJars <a>   Comma delimited list of additional jars to add
                           to the class path
 -c <arg>                  Continue processing even if one of the JSON
                           configuration file is invalid.
 -e                        Run endlessly. Default false.
 -f <arg>                  A single json file to execute.
 -h                        Help
 -j <arg>                  Directory where json configuration is stored.
                           Default is .
 -q <arg>                  Path to quartz configuration file.
 -s <arg>                  Seconds between server job runs (not defined
                           with cron). Default: 60
  1. Download the latest JAR file jmxtrans-251-all.jar and install it somewhere (e.g. next to the install directory of your primary or standalone node).
  2. Copy the JSON file from <installation path>/product/<product version>/etc/jmxtrans-decision-insight-essential.json to a directory (e.g. in the same directory as the JAR file).
  3. You might want to edit the JSON file to change the credentials and the port where the node listens for JMX connections. The default port is 1099:

    {
         "servers" : [{
             "host" : "localhost" ,
             "port" : "1099" ,
             "username" : "admin",
             "password" : "admin",
             "queries" : [{
             ...
             }]
         }]
    }
  4. When the node is started, start the tool with:

    java -jar jmxtrans-251-all.jar -f jmxtrans-decision-insight-essential.json

    If you have secured JMX to encrypt connections using SSL, you should provide a keystore with the right certificate. Here is an example of the command line to start the tool in this case:

    java -Djavax.net.ssl.trustStore=decision-insight-ssl.keystore -Djavax.net.ssl.trustStorePassword=secret -jar jmxtrans-251-all.jar -f jmxtrans-decision-insight-essential.json

    On Linux, the following error can be displayed but you can safely discard it:

    log4j:ERROR setFile(null,true) call failed.
    java.io.FileNotFoundException: /jmxtrans.log (Permission denied)

    The tool will start collecting metrics every 60 seconds and write results in file REPORT_PATH/jmxtrans.txt as long as the JVM is running.

To stop collecting the metrics, simply stop or kill the Java process (CTRL+C or kill <jmxtrans PID>).

You can also launch the tool in the background with:

nohup java -jar jmxtrans-251-all.jar -f jmxtrans-decision-insight-essential.json &

The REPORT_PATH/jmxtrans.txt output file is open in overwrite mode. Don't forget to rename the previous file if you launch different sessions.

Related Links