use of org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig in project opennms by OpenNMS.
the class JmxDatacollectionConfiggeneratorTest method testGenerateJmxConfigModelUsingMbeanFilter.
@Test
public void testGenerateJmxConfigModelUsingMbeanFilter() throws MBeanServerQueryException, IOException, JMException {
List<String> mbeanIds = new ArrayList<>();
mbeanIds.add("java.lang:type=GarbageCollector,name=PS MarkSweep");
mbeanIds.add("java.lang:type=GarbageCollector,name=PS Scavenge");
JmxDatacollectionConfig jmxConfigModel = jmxConfiggenerator.generateJmxConfigModel(mbeanIds, platformMBeanServer, "testService", true, true, dictionary);
Assert.assertNotNull(jmxConfigModel);
LOG.info(prettyPrint(jmxConfigModel));
Assert.assertEquals(2, jmxConfigModel.getJmxCollectionList().get(0).getMbeans().size());
for (Mbean eachMbean : jmxConfigModel.getJmxCollectionList().get(0).getMbeans()) {
Assert.assertEquals(2, eachMbean.getAttribList().size());
Assert.assertEquals(0, eachMbean.getCompAttribList().size());
}
}
use of org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig in project opennms by OpenNMS.
the class JmxDatacollectionConfiggeneratorTest method testGenerateJmxConfigModelSkipNonNumber.
@Test
public void testGenerateJmxConfigModelSkipNonNumber() throws MBeanServerQueryException, IOException, JMException {
JmxDatacollectionConfig jmxConfigModel = jmxConfiggenerator.generateJmxConfigModel(platformMBeanServer, "testService", true, false, dictionary);
Assert.assertEquals(1, jmxConfigModel.getJmxCollectionList().size());
Assert.assertTrue(10 < jmxConfigModel.getJmxCollectionList().get(0).getMbeans().size());
Mbean mbean = findMbean(jmxConfigModel, "org.opennms.tools.jmxconfiggenerator.jmxconfig.JmxTest");
Assert.assertNotNull(mbean);
Assert.assertEquals(5, mbean.getAttribList().size());
LOG.info(prettyPrint(jmxConfigModel));
}
use of org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig in project opennms by OpenNMS.
the class JmxDatacollectionConfiggeneratorTest method testGenerateJmxConfigModelUsingIdFilter.
@Test
public void testGenerateJmxConfigModelUsingIdFilter() throws MBeanServerQueryException, IOException, JMException {
List<String> mbeanIds = new ArrayList<>();
mbeanIds.add("java.lang:type=GarbageCollector,name=PS MarkSweep:CollectionCount");
mbeanIds.add("java.lang:type=GarbageCollector,name=PS Scavenge:CollectionTime");
JmxDatacollectionConfig jmxConfigModel = jmxConfiggenerator.generateJmxConfigModel(mbeanIds, platformMBeanServer, "testService", true, true, dictionary);
Assert.assertNotNull(jmxConfigModel);
LOG.info(prettyPrint(jmxConfigModel));
Assert.assertEquals(2, jmxConfigModel.getJmxCollectionList().get(0).getMbeans().size());
for (Mbean eachMbean : jmxConfigModel.getJmxCollectionList().get(0).getMbeans()) {
Assert.assertEquals(1, eachMbean.getAttribList().size());
Assert.assertEquals(0, eachMbean.getCompAttribList().size());
}
}
use of org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig 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.getJmxCollectionList()) {
output.addJmxCollection(clone(jmxCollection));
}
return output;
}
Aggregations