Search in sources :

Example 1 with LatencyThresholdingSet

use of org.opennms.netmgt.threshd.LatencyThresholdingSet in project opennms by OpenNMS.

the class LatencyStoringServiceMonitorAdaptor method applyThresholds.

private void applyThresholds(String rrdPath, MonitoredService service, String dsName, Map<String, Number> entries) {
    try {
        if (m_thresholdingSet == null) {
            RrdRepository repository = new RrdRepository();
            repository.setRrdBaseDir(new File(rrdPath));
            m_thresholdingSet = new LatencyThresholdingSet(service.getNodeId(), service.getIpAddr(), service.getSvcName(), service.getNodeLocation(), repository, m_resourceStorageDao);
        }
        LinkedHashMap<String, Double> attributes = new LinkedHashMap<String, Double>();
        for (String ds : entries.keySet()) {
            Number sampleValue = entries.get(ds);
            if (sampleValue == null) {
                attributes.put(ds, Double.NaN);
            } else {
                attributes.put(ds, sampleValue.doubleValue());
            }
        }
        if (m_thresholdingSet.isNodeInOutage()) {
            LOG.info("applyThresholds: the threshold processing will be skipped because the service {} is on a scheduled outage.", service);
        } else if (m_thresholdingSet.hasThresholds(attributes)) {
            List<Event> events = m_thresholdingSet.applyThresholds(dsName, attributes);
            if (events.size() > 0) {
                ThresholdingEventProxy proxy = new ThresholdingEventProxy();
                proxy.add(events);
                proxy.sendAllEvents();
            }
        }
    } catch (Throwable e) {
        LOG.error("Failed to threshold on {} for {} because of an exception", service, dsName, e);
    }
}
Also used : ThresholdingEventProxy(org.opennms.netmgt.threshd.ThresholdingEventProxy) LatencyThresholdingSet(org.opennms.netmgt.threshd.LatencyThresholdingSet) List(java.util.List) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) File(java.io.File) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)1 LatencyThresholdingSet (org.opennms.netmgt.threshd.LatencyThresholdingSet)1 ThresholdingEventProxy (org.opennms.netmgt.threshd.ThresholdingEventProxy)1