Search in sources :

Example 1 with CompMember

use of org.opennms.netmgt.config.collectd.jmx.CompMember in project opennms by OpenNMS.

the class JMXDataCollectionConfigDao method getMBeanInfo.

public static Map<String, BeanInfo> getMBeanInfo(JmxCollection collection) {
    final Map<String, BeanInfo> map = new HashMap<String, BeanInfo>();
    if (collection == null) {
        return Collections.unmodifiableMap(map);
    }
    for (Mbean mbean : collection.getMbeans()) {
        BeanInfo beanInfo = new BeanInfo();
        beanInfo.setMbeanName(mbean.getName());
        beanInfo.setObjectName(mbean.getObjectname());
        beanInfo.setKeyField(mbean.getKeyfield());
        beanInfo.setExcludes(mbean.getExclude());
        beanInfo.setKeyAlias(mbean.getKeyAlias());
        List<String> attribNameList = new ArrayList<String>();
        List<String> compAttribNameList = new ArrayList<String>();
        for (CompAttrib myCa : mbean.getCompAttribList()) {
            for (CompMember myCm : myCa.getCompMemberList()) {
                attribNameList.add(myCa.getName() + "|" + myCm.getName());
                compAttribNameList.add(myCa.getName() + "|" + myCm.getName());
            }
        }
        for (Attrib myA : mbean.getAttribList()) {
            attribNameList.add(myA.getName());
        }
        beanInfo.setAttributes(attribNameList);
        beanInfo.setCompositeAttributes(compAttribNameList);
        map.put(mbean.getObjectname(), beanInfo);
    }
    return Collections.unmodifiableMap(map);
}
Also used : HashMap(java.util.HashMap) Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) ArrayList(java.util.ArrayList) CompAttrib(org.opennms.netmgt.config.collectd.jmx.CompAttrib) CompAttrib(org.opennms.netmgt.config.collectd.jmx.CompAttrib) Attrib(org.opennms.netmgt.config.collectd.jmx.Attrib) CompMember(org.opennms.netmgt.config.collectd.jmx.CompMember)

Example 2 with CompMember

use of org.opennms.netmgt.config.collectd.jmx.CompMember in project opennms by OpenNMS.

the class DefaultJmxCollector method collect.

private void collect(MBeanServerConnection concreteConnection, JmxCollection jmxCollection, JmxSampleProcessor sampleProcessor) {
    if (jmxCollection == null || jmxCollection.getMbeanCount() < 1) {
        logger.info("No MBeans to collect.");
        return;
    }
    try {
        for (Mbean eachMbean : jmxCollection.getMbeans()) {
            logger.debug("Collecting MBean (objectname={}, wildcard={})", eachMbean.getObjectname(), isWildcard(eachMbean.getObjectname()));
            final Collection<ObjectName> objectNames = getObjectNames(concreteConnection, eachMbean.getObjectname());
            for (ObjectName eachObjectName : objectNames) {
                logger.debug("Collecting ObjectName {}", eachObjectName);
                boolean collect = canBeCollected(concreteConnection, eachObjectName, eachMbean.getKeyfield(), eachMbean.getExclude());
                if (collect) {
                    List<String> attributeNames = extractAttributeNames(eachMbean);
                    List<Attribute> attributes = getAttributes(concreteConnection, eachObjectName, attributeNames);
                    for (Attribute eachAttribute : attributes) {
                        if (eachAttribute.getValue() instanceof CompositeData) {
                            CompositeData compositeData = (CompositeData) eachAttribute.getValue();
                            for (CompMember eachCompositeMember : getCompositeMembers(eachMbean, eachAttribute.getName())) {
                                JmxCompositeSample sample = new JmxCompositeSample(eachMbean, eachAttribute, compositeData, eachCompositeMember);
                                logger.debug("Collected sample {}", sample);
                                sampleProcessor.process(sample);
                            }
                        } else {
                            JmxAttributeSample sample = new JmxAttributeSample(eachMbean, eachAttribute);
                            logger.debug("Collected sample {}", sample);
                            sampleProcessor.process(sample);
                        }
                    }
                } else {
                    logger.debug("Skip ObjectName {}", eachObjectName);
                }
            }
        }
    } catch (JMException e) {
        logger.error("Could not collect data", e);
    } catch (IOException e) {
        logger.error("Could not communicate with MBeanServer", e);
    }
}
Also used : Attribute(javax.management.Attribute) CompositeData(javax.management.openmbean.CompositeData) JmxCompositeSample(org.opennms.netmgt.jmx.samples.JmxCompositeSample) IOException(java.io.IOException) ObjectName(javax.management.ObjectName) CompMember(org.opennms.netmgt.config.collectd.jmx.CompMember) Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) JMException(javax.management.JMException) JmxAttributeSample(org.opennms.netmgt.jmx.samples.JmxAttributeSample)

Example 3 with CompMember

use of org.opennms.netmgt.config.collectd.jmx.CompMember in project opennms by OpenNMS.

the class JMXDataCollectionConfigDao method getAttributeMap.

public static Map<String, List<Attrib>> getAttributeMap(JmxCollection collection, String aSysoid, String anAddress) {
    final Map<String, List<Attrib>> attributeMap = new HashMap<String, List<Attrib>>();
    if (aSysoid == null) {
        LOG.debug("getMibObjectList: aSysoid parameter is NULL...");
        return attributeMap;
    }
    if (collection == null) {
        return attributeMap;
    }
    for (Mbean mbean : collection.getMbeans()) {
        // Make sure to create a new ArrayList because we add to it below
        List<Attrib> list = new ArrayList<Attrib>(mbean.getAttribList());
        for (CompAttrib compAttrib : mbean.getCompAttribList()) {
            for (CompMember compMember : compAttrib.getCompMemberList()) {
                Attrib attribWrapper = new Attrib();
                attribWrapper.setName(compAttrib.getName() + "|" + compMember.getName());
                attribWrapper.setAlias(compMember.getAlias());
                attribWrapper.setType(compMember.getType());
                list.add(attribWrapper);
            }
        }
        attributeMap.put(mbean.getObjectname(), list);
    }
    return attributeMap;
}
Also used : HashMap(java.util.HashMap) Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CompAttrib(org.opennms.netmgt.config.collectd.jmx.CompAttrib) CompAttrib(org.opennms.netmgt.config.collectd.jmx.CompAttrib) Attrib(org.opennms.netmgt.config.collectd.jmx.Attrib) CompMember(org.opennms.netmgt.config.collectd.jmx.CompMember)

Aggregations

CompMember (org.opennms.netmgt.config.collectd.jmx.CompMember)3 Mbean (org.opennms.netmgt.config.collectd.jmx.Mbean)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Attrib (org.opennms.netmgt.config.collectd.jmx.Attrib)2 CompAttrib (org.opennms.netmgt.config.collectd.jmx.CompAttrib)2 IOException (java.io.IOException)1 List (java.util.List)1 Attribute (javax.management.Attribute)1 JMException (javax.management.JMException)1 ObjectName (javax.management.ObjectName)1 CompositeData (javax.management.openmbean.CompositeData)1 JmxAttributeSample (org.opennms.netmgt.jmx.samples.JmxAttributeSample)1 JmxCompositeSample (org.opennms.netmgt.jmx.samples.JmxCompositeSample)1