Search in sources :

Example 1 with JmxCollection

use of org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection in project opennms by OpenNMS.

the class JmxDatacollectionConfiggenerator method generateJmxConfigModel.

public JmxDatacollectionConfig generateJmxConfigModel(List<String> ids, MBeanServerConnection mBeanServerConnection, String serviceName, Boolean runStandardVmBeans, Boolean skipNonNumber, Map<String, String> dictionary) throws MBeanServerQueryException, IOException, JMException {
    logger.debug("Startup values: \n serviceName: " + serviceName + "\n runStandardVmBeans: " + runStandardVmBeans + "\n dictionary" + dictionary);
    aliasList.clear();
    aliasMap.clear();
    nameCutter.setDictionary(dictionary);
    final QueryResult queryResult = queryMbeanServer(ids, mBeanServerConnection, runStandardVmBeans);
    final JmxDatacollectionConfig xmlJmxDatacollectionConfig = createJmxDataCollectionConfig(serviceName, rrd);
    final JmxCollection xmlJmxCollection = xmlJmxDatacollectionConfig.getJmxCollection().get(0);
    for (QueryResult.MBeanResult eachMBeanResult : queryResult.getMBeanResults()) {
        final ObjectName objectName = eachMBeanResult.objectName;
        final Mbean xmlMbean = createMbean(objectName);
        final QueryResult.AttributeResult attributeResult = eachMBeanResult.attributeResult;
        for (MBeanAttributeInfo jmxBeanAttributeInfo : attributeResult.attributes) {
            // check for CompositeData
            if ("javax.management.openmbean.CompositeData".equals(jmxBeanAttributeInfo.getType())) {
                CompAttrib compAttrib = createCompAttrib(mBeanServerConnection, objectName, jmxBeanAttributeInfo, skipNonNumber);
                if (compAttrib != null) {
                    xmlMbean.getCompAttrib().add(compAttrib);
                }
            }
            if (skipNonNumber && !numbers.contains(jmxBeanAttributeInfo.getType())) {
                logger.warn("The type of attribute '{}' is '{}' and '--skipNonNumber' is set. Ignoring.", jmxBeanAttributeInfo.getName(), jmxBeanAttributeInfo.getType());
            } else {
                Attrib xmlJmxAttribute = createAttr(jmxBeanAttributeInfo);
                xmlMbean.getAttrib().add(xmlJmxAttribute);
            }
        }
        if (!xmlMbean.getAttrib().isEmpty() || !xmlMbean.getCompAttrib().isEmpty()) {
            xmlJmxCollection.getMbeans().getMbean().add(xmlMbean);
        }
    }
    if (xmlJmxCollection.getMbeans().getMbean().size() != queryResult.getMBeanResults().size()) {
        logger.warn("Queried {} MBeans, but only got {} in the result set.", queryResult.getMBeanResults().size(), xmlJmxCollection.getMbeans().getMbean().size());
    }
    return xmlJmxDatacollectionConfig;
}
Also used : QueryResult(org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult) Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean) JmxDatacollectionConfig(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxDatacollectionConfig) CompAttrib(org.opennms.xmlns.xsd.config.jmx_datacollection.CompAttrib) JmxCollection(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) CompAttrib(org.opennms.xmlns.xsd.config.jmx_datacollection.CompAttrib) Attrib(org.opennms.xmlns.xsd.config.jmx_datacollection.Attrib) ObjectName(javax.management.ObjectName)

Example 2 with JmxCollection

use of org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection in project opennms by OpenNMS.

the class JmxCollectionCloner method clone.

/**
	 * Clones a whole JmxCollection. Makes a deep copy!
	 * 
	 * @param input
	 * @return
	 */
private static JmxCollection clone(JmxCollection input) {
    JmxCollection output = new JmxCollection();
    output.setMaxVarsPerPdu(input.getMaxVarsPerPdu());
    output.setName(input.getName());
    output.setRrd(clone(input.getRrd()));
    output.setMbeans(clone(input.getMbeans()));
    return output;
}
Also used : JmxCollection(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection)

Example 3 with JmxCollection

use of org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection in project opennms by OpenNMS.

the class JmxDatacollectionConfiggenerator method createJmxDataCollectionConfig.

private JmxDatacollectionConfig createJmxDataCollectionConfig(String serviceName, Rrd rrd) {
    final JmxDatacollectionConfig xmlJmxDatacollectionConfig = new JmxDatacollectionConfig();
    final JmxCollection xmlJmxCollection = new JmxCollection();
    xmlJmxCollection.setName("JSR160-" + serviceName);
    xmlJmxCollection.setRrd(rrd);
    xmlJmxDatacollectionConfig.getJmxCollection().add(xmlJmxCollection);
    xmlJmxCollection.setMbeans(new Mbeans());
    return xmlJmxDatacollectionConfig;
}
Also used : JmxDatacollectionConfig(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxDatacollectionConfig) JmxCollection(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection) Mbeans(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbeans)

Example 4 with JmxCollection

use of org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection in project opennms by OpenNMS.

the class JmxConfigReader method generateReportsByJmxDatacollectionConfig.

public Collection<Report> generateReportsByJmxDatacollectionConfig(JmxDatacollectionConfig inputConfig) {
    Collection<Report> reports = new ArrayList<Report>();
    for (JmxCollection jmxCollection : inputConfig.getJmxCollection()) {
        logger.debug("jmxCollection: '{}'", jmxCollection.getName());
        for (Mbean mbean : jmxCollection.getMbeans().getMbean()) {
            reports.addAll(generateMbeanReportsByMBean(mbean));
            reports.addAll(generateAttributeReportsByMBean(mbean));
            reports.addAll(generateCompositeReportsByMBean(mbean));
            reports.addAll(generateCompositeMemberReportsByMBean(mbean));
        }
    }
    return reports;
}
Also used : Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean) ArrayList(java.util.ArrayList) JmxCollection(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection)

Example 5 with JmxCollection

use of org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection in project opennms by OpenNMS.

the class JmxCollectionCloner method clone.

/**
	 * Clones a whole JmxCollectionConfig. Makes a deep copy!
	 * 
	 * @param input
	 * @return
	 */
public static JmxDatacollectionConfig clone(JmxDatacollectionConfig input) {
    JmxDatacollectionConfig output = new JmxDatacollectionConfig();
    output.setRrdRepository(input.getRrdRepository());
    for (JmxCollection jmxCollection : input.getJmxCollection()) {
        output.getJmxCollection().add(clone(jmxCollection));
    }
    return output;
}
Also used : JmxDatacollectionConfig(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxDatacollectionConfig) JmxCollection(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection)

Aggregations

JmxCollection (org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection)5 JmxDatacollectionConfig (org.opennms.xmlns.xsd.config.jmx_datacollection.JmxDatacollectionConfig)3 Mbean (org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean)2 ArrayList (java.util.ArrayList)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 ObjectName (javax.management.ObjectName)1 QueryResult (org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult)1 Attrib (org.opennms.xmlns.xsd.config.jmx_datacollection.Attrib)1 CompAttrib (org.opennms.xmlns.xsd.config.jmx_datacollection.CompAttrib)1 Mbeans (org.opennms.xmlns.xsd.config.jmx_datacollection.Mbeans)1