Skip to main content

JMX CLI Documentation

JMX (Java Management Extensions) is a standard API for monitoring and managing resources such as applications, devices, and services. It is widely used for accessing Java Virtual Machine (JVM) metrics and MBeans (Managed Beans).

The MetricsHub JMX CLI allows users to query MBeans from a JMX server to fetch attributes, filter key properties, and extract JVM metrics.

Syntax

jmxcli HOSTNAME --object-name OBJECT_NAME [--port PORT] [--username USERNAME] [--password PASSWORD] [--timeout TIMEOUT] [--attributes ATTRIBUTES] [--key-properties KEY_PROPERTIES] [-v]

Options

OptionDescriptionDefault Value
HOSTNAMEHostname or IP address of the JMX server.None (required)
--object-nameJMX MBean object name or pattern (e.g., java.lang:type=Memory).None (required)
--portPort number for the JMX server.1099
--usernameUsername for JMX authentication.None
--passwordPassword for JMX authentication. If not provided, the CLI prompts interactively.None
--timeoutTimeout in seconds for the JMX request.30
--attributesComma-separated list of attributes to fetch from the MBean.None
--key-propertiesComma-separated list of key properties to include in the result set.None
-vEnables verbose mode. Repeat (-vv) for increased verbosity.None
-h, -?, --helpDisplays detailed help information.None

Examples

Example 1: Querying Cassandra Metrics with JMX

jmxcli cassandra-01 --port 7199 --timeout 60s \
--object-name org.apache.cassandra.metrics:type=Table,keyspace=system,scope=*,name=TotalDiskSpaceUsed \
--key-properties scope \
--attributes Count

Example 2: Querying a JVM's Runtime Attributes

jmxcli jvm-host --object-name java.lang:type=Runtime --attributes Uptime,StartTime

Example 3: JMX Query with Authentication and Interactive Password Prompt

jmxcli app-host --username monitor --object-name java.lang:type=Threading --attributes ThreadCount,PeakThreadCount --timeout 45

If the --password option is omitted, the CLI prompts securely for the password.