Search in sources :

Example 6 with JmxCollection

use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.

the class JMXCollectorComplianceTest method getRequiredBeans.

@Override
public Map<String, Object> getRequiredBeans() {
    MBeanServer mbeanServer = new MBeanServer();
    JmxConfigDao jmxConfigDao = mock(JmxConfigDao.class, RETURNS_DEEP_STUBS);
    final String host = InetAddrUtils.str(InetAddrUtils.getLocalHostAddress());
    when(jmxConfigDao.getConfig().lookupMBeanServer(host, JmxServerConnector.DEFAULT_OPENNMS_JMX_PORT)).thenReturn(mbeanServer);
    JmxCollection collection = new JmxCollection();
    JMXDataCollectionConfigDao jmxCollectionDao = mock(JMXDataCollectionConfigDao.class, RETURNS_DEEP_STUBS);
    when(jmxCollectionDao.getJmxCollection(COLLECTION)).thenReturn(collection);
    return new ImmutableMap.Builder<String, Object>().put("jmxConfigDao", jmxConfigDao).put("jmxDataCollectionConfigDao", jmxCollectionDao).build();
}
Also used : JMXDataCollectionConfigDao(org.opennms.netmgt.config.JMXDataCollectionConfigDao) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection) JmxConfigDao(org.opennms.netmgt.dao.jmx.JmxConfigDao) ImmutableMap(com.google.common.collect.ImmutableMap) MBeanServer(org.opennms.netmgt.config.jmx.MBeanServer)

Example 7 with JmxCollection

use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.

the class JMXDataCollectionConfigDao method translateConfig.

@Override
public JmxDatacollectionConfig translateConfig(JmxDatacollectionConfig config) {
    for (JmxCollection collection : config.getJmxCollectionList()) {
        if (collection.hasImportMbeans()) {
            for (String importMbeans : collection.getImportGroupsList()) {
                final File file = getOpennmsHome().resolve(Paths.get("etc", importMbeans)).toFile();
                LOG.debug("parseJmxMbeans: parsing {}", file);
                final Mbeans mbeans = JaxbUtils.unmarshal(Mbeans.class, new FileSystemResource(file));
                collection.addMbeans(mbeans.getMbeanList());
            }
        }
    }
    return config;
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection) File(java.io.File) Mbeans(org.opennms.netmgt.config.collectd.jmx.Mbeans)

Example 8 with JmxCollection

use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.

the class JMXDataCollectionConfigDao method buildCollectionMap.

/**
     * Build collection map which is a hash map of Collection
     * objects indexed by collection name...also build
     * collection group map which is a hash map indexed
     * by collection name with a hash map as the value
     * containing a map of the collections's group names
     * to the Group object containing all the information
     * for that group. So the associations are:
     * <p/>
     * CollectionMap
     * collectionName -> Collection
     * <p/>
     * CollectionGroupMap
     * collectionName -> groupMap
     * <p/>
     * GroupMap
     * groupMapName -> Group
     * <p/>
     * This is parsed and built at initialization for
     * faster processing at run-time.
     */
private void buildCollectionMap(JmxDatacollectionConfig config) {
    m_lock.writeLock().lock();
    try {
        m_collectionMap.clear();
        // global to all the mbeans?
        for (JmxCollection collection : config.getJmxCollectionList()) {
            // Build group map for this collection
            Map<String, Mbean> groupMap = new HashMap<String, Mbean>();
            for (Mbean mbean : collection.getMbeans()) {
                groupMap.put(mbean.getName(), mbean);
            }
            m_collectionMap.put(collection.getName(), collection);
        }
    } finally {
        m_lock.writeLock().unlock();
    }
}
Also used : HashMap(java.util.HashMap) Mbean(org.opennms.netmgt.config.collectd.jmx.Mbean) JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection)

Example 9 with JmxCollection

use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.

the class JMXDataCollectionConfigDao method getJmxCollection.

public JmxCollection getJmxCollection(String collectionName) {
    // Try retrieving the object, which will trigger a reload of the cache if it changed
    getObject();
    m_lock.readLock().lock();
    try {
        JmxCollection collection = m_collectionMap.get(collectionName);
        if (collection == null) {
            LOG.warn("No JMX Config for collection '{}' found", collectionName);
        }
        return collection;
    } finally {
        m_lock.readLock().unlock();
    }
}
Also used : JmxCollection(org.opennms.netmgt.config.collectd.jmx.JmxCollection)

Aggregations

JmxCollection (org.opennms.netmgt.config.collectd.jmx.JmxCollection)9 HashMap (java.util.HashMap)3 MBeanServer (org.opennms.netmgt.config.jmx.MBeanServer)3 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 InetAddress (java.net.InetAddress)1 List (java.util.List)1 Map (java.util.Map)1 ParameterMap (org.opennms.core.utils.ParameterMap)1 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)1 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)1 JMXDataCollectionConfigDao (org.opennms.netmgt.config.JMXDataCollectionConfigDao)1 Mbean (org.opennms.netmgt.config.collectd.jmx.Mbean)1 Mbeans (org.opennms.netmgt.config.collectd.jmx.Mbeans)1 JmxConfigDao (org.opennms.netmgt.dao.jmx.JmxConfigDao)1 JmxCollectorConfig (org.opennms.netmgt.jmx.JmxCollectorConfig)1 JmxSampleProcessor (org.opennms.netmgt.jmx.JmxSampleProcessor)1 DefaultJmxCollector (org.opennms.netmgt.jmx.impl.DefaultJmxCollector)1 AbstractJmxSample (org.opennms.netmgt.jmx.samples.AbstractJmxSample)1 JmxAttributeSample (org.opennms.netmgt.jmx.samples.JmxAttributeSample)1