Search in sources :

Example 1 with MBeanServerQuery

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);
    }
}
Also used : MBeanServerQuery(org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQuery) QueryResult(org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Example 2 with MBeanServerQuery

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;
}
Also used : MBeanServerQuery(org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQuery) LogAdapter(org.opennms.features.jmxconfiggenerator.log.LogAdapter) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) HashMap(java.util.HashMap) Collections2(com.google.common.collect.Collections2) ArrayList(java.util.ArrayList) QueryResult(org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult) Map(java.util.Map) FilterCriteria(org.opennms.features.jmxconfiggenerator.jmxconfig.query.FilterCriteria) AttributeType(org.opennms.netmgt.collection.api.AttributeType) JaxbUtils(org.opennms.core.xml.JaxbUtils) MBeanServerConnection(javax.management.MBeanServerConnection) Collection(java.util.Collection) Set(java.util.Set) CompositeData(javax.management.openmbean.CompositeData) IOException(java.io.IOException) ObjectName(javax.management.ObjectName) CompAttrib(org.opennms.netmgt.config.collectd.jmx.CompAttrib) File(java.io.File) JmxDatacollectionConfig(org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig) Rrd(org.opennms.netmgt.config.collectd.jmx.Rrd) List(java.util.List) Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) CompMember(org.opennms.netmgt.config.collectd.jmx.CompMember) JMException(javax.management.JMException) Attrib(org.opennms.netmgt.config.collectd.jmx.Attrib) MBeanServerQueryException(org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQueryException) NameCutter(org.opennms.features.namecutter.NameCutter) MBeanServerQuery(org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQuery) QueryResult(org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult)

Aggregations

MBeanAttributeInfo (javax.management.MBeanAttributeInfo)2 MBeanServerQuery (org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQuery)2 QueryResult (org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult)2 Collections2 (com.google.common.collect.Collections2)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 JMException (javax.management.JMException)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 ObjectName (javax.management.ObjectName)1 CompositeData (javax.management.openmbean.CompositeData)1 JaxbUtils (org.opennms.core.xml.JaxbUtils)1 FilterCriteria (org.opennms.features.jmxconfiggenerator.jmxconfig.query.FilterCriteria)1 MBeanServerQueryException (org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQueryException)1 LogAdapter (org.opennms.features.jmxconfiggenerator.log.LogAdapter)1