A library to collect JMX metrics.
- Add the Segence OSS Releases Maven repo to your project, click here for instructions
- Import the artifact, click here for instructions
- 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);