Search in sources :

Example 1 with HttpCollection

use of org.opennms.netmgt.config.httpdatacollection.HttpCollection in project opennms by OpenNMS.

the class HttpCollector method collect.

/** {@inheritDoc} */
@Override
public CollectionSet collect(CollectionAgent agent, Map<String, Object> parameters) {
    final HttpCollection collection = (HttpCollection) parameters.get(HTTP_COLLECTION_KEY);
    final CollectionSetBuilder collectionSetBuilder = new CollectionSetBuilder(agent);
    final HttpCollectorAgent httpCollectorAgent = new HttpCollectorAgent(agent, parameters, collection, collectionSetBuilder);
    httpCollectorAgent.collect();
    return collectionSetBuilder.build();
}
Also used : HttpCollection(org.opennms.netmgt.config.httpdatacollection.HttpCollection) CollectionSetBuilder(org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)

Example 2 with HttpCollection

use of org.opennms.netmgt.config.httpdatacollection.HttpCollection in project opennms by OpenNMS.

the class HttpCollectionConfigFactory method getHttpCollection.

/**
     * <p>getHttpCollection</p>
     *
     * @param collectionName a {@link java.lang.String} object.
     * @return a {@link org.opennms.netmgt.config.httpdatacollection.HttpCollection} object.
     */
public HttpCollection getHttpCollection(String collectionName) {
    try {
        updateFromFile();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    List<HttpCollection> collections = m_config.getHttpCollection();
    HttpCollection collection = null;
    for (HttpCollection coll : collections) {
        if (coll.getName().equalsIgnoreCase(collectionName)) {
            collection = coll;
            break;
        }
    }
    if (collection == null) {
        throw new IllegalArgumentException("getHttpCollection: collection name: " + collectionName + " specified in collectd configuration not found in http collection configuration.");
    }
    return collection;
}
Also used : HttpCollection(org.opennms.netmgt.config.httpdatacollection.HttpCollection) IOException(java.io.IOException)

Example 3 with HttpCollection

use of org.opennms.netmgt.config.httpdatacollection.HttpCollection in project opennms by OpenNMS.

the class HttpCollector method getRuntimeAttributes.

@Override
public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) {
    final Map<String, Object> runtimeAttributes = new HashMap<>();
    final String collectionName = ParameterMap.getKeyedString(parameters, "collection", ParameterMap.getKeyedString(parameters, "http-collection", null));
    final HttpCollection collection = HttpCollectionConfigFactory.getInstance().getHttpCollection(collectionName);
    if (collection == null) {
        throw new IllegalArgumentException(String.format("HttpCollector: No collection found with name '%s'.", collectionName));
    }
    runtimeAttributes.put(HTTP_COLLECTION_KEY, collection);
    return runtimeAttributes;
}
Also used : HttpCollection(org.opennms.netmgt.config.httpdatacollection.HttpCollection) HashMap(java.util.HashMap)

Aggregations

HttpCollection (org.opennms.netmgt.config.httpdatacollection.HttpCollection)3 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)1