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