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();
}
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;
}
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;
}
Aggregations