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);
}
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);
}
}
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;
}
Aggregations