use of org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQuery in project opennms by OpenNMS.
the class QueryCommand method execute.
@Override
protected void execute(MBeanServerConnection mbeanServerConnection) throws MBeanServerQueryException, IOException {
if (domainOnlyFlag && (filter == null || filter.isEmpty())) {
for (String eachDomain : mbeanServerConnection.getDomains()) {
LOG.info(eachDomain);
}
return;
}
MBeanServerQuery queryBuilder = new MBeanServerQuery().withFilters(filter).withIgnoresFilter(ignoreFilter).fetchValues(includeValues).showMBeansWithoutAttributes(all).sort(true);
QueryResult result = queryBuilder.execute(mbeanServerConnection);
if (idOnlyFlag) {
for (QueryResult.MBeanResult eachResult : result.getMBeanResults()) {
for (MBeanAttributeInfo eachAttributeInfo : eachResult.attributeResult.attributes) {
LOG.info(toAttributeId(eachResult.objectName, eachAttributeInfo));
}
}
} else {
prettyPrint(result);
}
}
use of org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQuery in project opennms by OpenNMS.
the class JmxDatacollectionConfiggenerator method queryMbeanServer.
private QueryResult queryMbeanServer(List<String> ids, MBeanServerConnection mBeanServerConnection, boolean runStandardVmBeans) throws MBeanServerQueryException {
final MBeanServerQuery query = new MBeanServerQuery().withFilters(ids).fetchValues(// we do not fetch values to improve collection speed
false).showMBeansWithoutAttributes(// we don't need them
false).sort(// sorting makes finding attributes easier
true);
if (!runStandardVmBeans) {
query.withIgnoresFilter(Collections2.transform(standardVmBeans, input -> input + ":*"));
}
final QueryResult result = query.execute(mBeanServerConnection);
return result;
}
Aggregations