Search in sources :

Example 1 with LatencyCollectionAttribute

use of org.opennms.netmgt.poller.LatencyCollectionAttribute 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));
}
Also used : LatencyCollectionAttribute(org.opennms.netmgt.poller.LatencyCollectionAttribute) CollectionAttribute(org.opennms.netmgt.collection.api.CollectionAttribute) LatencyCollectionAttribute(org.opennms.netmgt.poller.LatencyCollectionAttribute) LatencyCollectionResource(org.opennms.netmgt.poller.LatencyCollectionResource) HashMap(java.util.HashMap) LatencyCollectionAttributeType(org.opennms.netmgt.poller.LatencyCollectionAttributeType) Date(java.util.Date)

Example 2 with LatencyCollectionAttribute

use of org.opennms.netmgt.poller.LatencyCollectionAttribute 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);
}
Also used : LatencyCollectionAttribute(org.opennms.netmgt.poller.LatencyCollectionAttribute) SingleResourceCollectionSet(org.opennms.netmgt.collection.support.SingleResourceCollectionSet) LatencyCollectionResource(org.opennms.netmgt.poller.LatencyCollectionResource) LatencyCollectionAttributeType(org.opennms.netmgt.poller.LatencyCollectionAttributeType) CollectionSetVisitor(org.opennms.netmgt.collection.api.CollectionSetVisitor) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) Date(java.util.Date)

Aggregations

Date (java.util.Date)2 LatencyCollectionAttribute (org.opennms.netmgt.poller.LatencyCollectionAttribute)2 LatencyCollectionAttributeType (org.opennms.netmgt.poller.LatencyCollectionAttributeType)2 LatencyCollectionResource (org.opennms.netmgt.poller.LatencyCollectionResource)2 HashMap (java.util.HashMap)1 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)1 CollectionSetVisitor (org.opennms.netmgt.collection.api.CollectionSetVisitor)1 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)1 SingleResourceCollectionSet (org.opennms.netmgt.collection.support.SingleResourceCollectionSet)1 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)1