Skip to content

Segence/jmx-collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4d413cc · Jan 6, 2025

History

20 Commits
Jan 1, 2025
Jan 6, 2025
Jan 6, 2025
Jan 1, 2025
Jan 1, 2025
Apr 20, 2018
Apr 20, 2018
Jan 6, 2025
Jan 1, 2025
Jan 6, 2025
Jan 1, 2025
Apr 20, 2018
Apr 20, 2018
Apr 20, 2018

Repository files navigation

JMX Collector

Workflow Status Coverage Status

A library to collect JMX metrics.

Usage

  1. Add the Segence OSS Releases Maven repo to your project, click here for instructions
  2. Import the artifact, click here for instructions
  3. Query JMX metrics by specifying some MBean names and attributes. Example:
import com.segence.commons.jmx.collector.JmxCollector

...

Map<ObjectName, Set<String>> mbeansAndAttributesToQuery = new HashMap<ObjectName, Set<String>>() {{
    try {
        put(
            new ObjectName("java.lang:type=OperatingSystem"),
            new HashSet<String>() {{
                add("Arch");
                add("AvailableProcessors");
            }}
        );
    } catch (MalformedObjectNameException e) {
        e.printStackTrace();
    }
}};

Set<MBeanMetricResult> results = JmxCollector.queryAsSet(mbeansAndAttributesToQuery);