Search in sources :

Example 1 with Mbean

use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.

the class JmxDatacollectionConfiggenerator method createMbean.

private Mbean createMbean(ObjectName objectName) {
    String typeAndOthers = objectName.getCanonicalName().substring(objectName.getCanonicalName().lastIndexOf("=") + 1);
    final Mbean mbean = new Mbean();
    mbean.setObjectname(objectName.toString());
    mbean.setName(objectName.getDomain() + "." + typeAndOthers);
    return mbean;
}
Also used : Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean)

Example 2 with Mbean

use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean 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;
}
Also used : QueryResult(org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult) Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean) JmxDatacollectionConfig(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxDatacollectionConfig) CompAttrib(org.opennms.xmlns.xsd.config.jmx_datacollection.CompAttrib) JmxCollection(org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) CompAttrib(org.opennms.xmlns.xsd.config.jmx_datacollection.CompAttrib) Attrib(org.opennms.xmlns.xsd.config.jmx_datacollection.Attrib) ObjectName(javax.management.ObjectName)

Example 3 with Mbean

use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.

the class MbeansHierarchicalContainer method updateDataSource.

protected void updateDataSource(List<Mbean> mbeanList) {
    clearContainer();
    for (Mbean eachMbean : mbeanList) {
        add(eachMbean);
    }
    sort(new Object[] { MBeansTree.MetaMBeansTreeItem.CAPTION }, new boolean[] { true });
}
Also used : Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean)

Example 4 with Mbean

use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.

the class MbeansHierarchicalContainer method addNodes.

private String addNodes(List nodesToAdd) {
    String rootItemId = null;
    Iterator it = nodesToAdd.iterator();
    while (it.hasNext()) {
        Object eachNode = it.next();
        boolean hasChildren = it.hasNext();
        if (eachNode instanceof Mbean) {
            hasChildren |= ((Mbean) eachNode).getCompAttrib() != null && !((Mbean) eachNode).getCompAttrib().isEmpty();
        }
        rootItemId = addNode(rootItemId, eachNode, hasChildren);
    }
    return rootItemId;
}
Also used : Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean) Iterator(java.util.Iterator)

Example 5 with Mbean

use of org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean in project opennms by OpenNMS.

the class UniqueAttributeNameValidatorTest method testNotEmpty.

@Test
public void testNotEmpty() {
    Mbean mbean = selectionManager.getSelectedMbeans().iterator().next();
    DefaultNameProvider nameProvider = new DefaultNameProvider(selectionManager);
    List<String> names = new ArrayList<>(nameProvider.getNamesMap().values());
    Assert.assertNotNull(names);
    Assert.assertEquals(3, names.size());
    Collections.sort(names);
    Assert.assertTrue(Arrays.equals(new String[] { "attrib1", "compMem1", "compMem2" }, names.toArray(new String[names.size()])));
    // alias clash
    mbean.getAttrib().add(TestHelper.createAttrib("attribute2", "attrib1"));
    names = new ArrayList<>(nameProvider.getNamesMap().values());
    Assert.assertEquals(4, names.size());
    UniqueAttributeNameValidator validator = new UniqueAttributeNameValidator(nameProvider);
    Assert.assertEquals(Boolean.TRUE.booleanValue(), validator.isValid("yes"));
    Assert.assertEquals(Boolean.TRUE.booleanValue(), validator.isValid("compMem1"));
    Assert.assertEquals(Boolean.FALSE.booleanValue(), validator.isValid("attrib1"));
}
Also used : Mbean(org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean) ArrayList(java.util.ArrayList) DefaultNameProvider(org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.DefaultNameProvider) Test(org.junit.Test)

Aggregations

Mbean (org.opennms.xmlns.xsd.config.jmx_datacollection.Mbean)18 CompAttrib (org.opennms.xmlns.xsd.config.jmx_datacollection.CompAttrib)7 Test (org.junit.Test)6 JmxDatacollectionConfig (org.opennms.xmlns.xsd.config.jmx_datacollection.JmxDatacollectionConfig)6 Attrib (org.opennms.xmlns.xsd.config.jmx_datacollection.Attrib)5 ArrayList (java.util.ArrayList)4 CompMember (org.opennms.xmlns.xsd.config.jmx_datacollection.CompMember)3 JmxCollection (org.opennms.xmlns.xsd.config.jmx_datacollection.JmxCollection)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 ObjectName (javax.management.ObjectName)1 Before (org.junit.Before)1 QueryResult (org.opennms.features.jmxconfiggenerator.jmxconfig.query.QueryResult)1 DefaultNameProvider (org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.DefaultNameProvider)1 SelectionManager (org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.SelectionManager)1 ValidationResult (org.opennms.features.vaadin.jmxconfiggenerator.ui.mbeans.validation.ValidationResult)1