Search in sources :

Example 11 with JmxDatacollectionConfig

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());
    }
}
Also used : Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) ArrayList(java.util.ArrayList) JmxDatacollectionConfig(org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig) Test(org.junit.Test)

Example 12 with JmxDatacollectionConfig

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));
}
Also used : Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) JmxDatacollectionConfig(org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig) Test(org.junit.Test)

Example 13 with JmxDatacollectionConfig

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());
    }
}
Also used : Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) ArrayList(java.util.ArrayList) JmxDatacollectionConfig(org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig) Test(org.junit.Test)

Example 14 with JmxDatacollectionConfig

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;
}
Also used : JmxDatacollectionConfig(org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection)

Aggregations

JmxDatacollectionConfig (org.opennms.netmgt.config.collectd.jmx.JmxDatacollectionConfig)14 Test (org.junit.Test)7 Mbean (org.opennms.netmgt.config.collectd.jmx.Mbean)6 JmxCollection (org.opennms.netmgt.config.collectd.jmx.JmxCollection)3 ArrayList (java.util.ArrayList)2 JmxDatacollectionConfiggenerator (org.opennms.features.jmxconfiggenerator.jmxconfig.JmxDatacollectionConfiggenerator)2 Attrib (org.opennms.netmgt.config.collectd.jmx.Attrib)2 CompAttrib (org.opennms.netmgt.config.collectd.jmx.CompAttrib)2 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 UnknownHostException (java.net.UnknownHostException)1 JMException (javax.management.JMException)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 ObjectName (javax.management.ObjectName)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 MBeanServerQueryException (org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQueryException)1 QueryResult (org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult)1 Slf4jLogAdapter (org.opennms.features.jmxconfiggenerator.log.Slf4jLogAdapter)1