use of org.opennms.netmgt.poller.LatencyCollectionAttributeType in project opennms by OpenNMS.
the class LatencyThresholdingSet method applyThresholds.
/*
* Apply thresholds definitions for specified service using attributesMap as current values.
* Return a list of events to be send if some thresholds must be triggered or be rearmed.
*/
/** {@inheritDoc} */
public List<Event> applyThresholds(String svcName, Map<String, Double> attributes) {
LatencyCollectionResource latencyResource = new LatencyCollectionResource(svcName, m_hostAddress, m_location);
LatencyCollectionAttributeType latencyType = new LatencyCollectionAttributeType();
Map<String, CollectionAttribute> attributesMap = new HashMap<String, CollectionAttribute>();
for (final Entry<String, Double> entry : attributes.entrySet()) {
final String ds = entry.getKey();
attributesMap.put(ds, new LatencyCollectionAttribute(latencyResource, latencyType, ds, entry.getValue()));
}
//The timestamp is irrelevant; latency is never a COUNTER (which is the only reason the date is used).
//Yes, we have to know a little too much about the implementation details of CollectionResourceWrapper to say that, but
// we have little choice
CollectionResourceWrapper resourceWrapper = new CollectionResourceWrapper(new Date(), m_nodeId, m_hostAddress, m_serviceName, m_repository, latencyResource, attributesMap, m_resourceStorageDao);
return Collections.unmodifiableList(applyThresholds(resourceWrapper, attributesMap));
}
use of org.opennms.netmgt.poller.LatencyCollectionAttributeType in project opennms by OpenNMS.
the class LatencyStoringServiceMonitorAdaptor method persistLatencySamples.
private void persistLatencySamples(MonitoredService service, Map<String, Number> entries, File rrdRepositoryRoot, String rrdBaseName) {
RrdRepository repository = new RrdRepository();
repository.setStep(m_pollerConfig.getStep(m_pkg));
repository.setRraList(m_pollerConfig.getRRAList(m_pkg));
repository.setHeartBeat(repository.getStep() * HEARTBEAT_STEP_MULTIPLIER);
repository.setRrdBaseDir(rrdRepositoryRoot);
// When making calls directly to RrdUtils#createRrd() and RrdUtils#updateRrd(),
// the behavior was as follows:
// 1) All samples get written to response/${ipAddr}/${rrdBaseName}.rrd
// This happens whether or not storeByGroup is enabled.
// 2) If multiple entries are present, the DSs are created in the same order that they
// appear in the map
LatencyCollectionResource latencyResource = new LatencyCollectionResource(service.getSvcName(), service.getIpAddr(), service.getNodeLocation());
for (final Entry<String, Number> entry : entries.entrySet()) {
final String ds = entry.getKey();
final Number value = entry.getValue() != null ? entry.getValue() : Double.NaN;
LatencyCollectionAttributeType latencyType = new LatencyCollectionAttributeType(rrdBaseName, ds);
latencyResource.addAttribute(new LatencyCollectionAttribute(latencyResource, latencyType, ds, value.doubleValue()));
}
ServiceParameters params = new ServiceParameters(Collections.emptyMap());
CollectionSetVisitor persister = m_persisterFactory.createPersister(params, repository, false, true, true);
SingleResourceCollectionSet collectionSet = new SingleResourceCollectionSet(latencyResource, new Date());
collectionSet.setStatus(CollectionStatus.SUCCEEDED);
collectionSet.visit(persister);
}
Aggregations