Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 1.22 KB

README.md

File metadata and controls

35 lines (28 loc) · 1.22 KB

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);