ThresholdingEventProxy
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.opennms.netmgt.threshd.ThresholdingEventProxy (Showing top 11 results out of 315)

origin: OpenNMS/opennms

  @Override
  protected ThresholdingEventProxy initialValue() {
    return new ThresholdingEventProxy();
  }
};
origin: OpenNMS/opennms

/**
 * Apply threshold for specific resource (and required attributes).
 * Send thresholds events (if exists).
 */
@Override
public void completeResource(CollectionResource resource) {
  List<Event> eventList = m_thresholdingSet.applyThresholds(resource, m_attributesMap, m_collectionTimestamp);
  ThresholdingEventProxy proxy = ThresholdingEventProxyFactory.getFactory().getProxy();
  proxy.add(eventList);
  proxy.sendAllEvents();
}

origin: OpenNMS/opennms

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);
}
}
origin: OpenNMS/opennms

/** {@inheritDoc} */
@Override
public void send(Event event) throws EventProxyException {
  add(event);
}
origin: OpenNMS/opennms

ThresholdingEventProxyFactory.getFactory().getProxy().removeAllEvents();
ThresholdingEventProxyFactory.getFactory().getProxy().sendAllEvents();
origin: OpenNMS/opennms

/**
 * <p>sendAllEvents</p>
 */
public void sendAllEvents() {
  if (m_events.size() > 0) {
    try {
      Log log = new Log();
      Events events = new Events();
      for (Event e : m_events) {
        events.addEvent(e);
      }
      log.setEvents(events);
      EventIpcManagerFactory.getIpcManager().sendNow(log);
    } catch (Throwable e) {
      LOG.info("sendAllEvents: Failed sending threshold events", e);
    }
    removeAllEvents();
  }
}
origin: OpenNMS/opennms

@Test
@JUnitTemporaryDatabase(tempDbClass=MockDatabase.class)
public void testBug3488() throws Exception {
  String ipAddress = "127.0.0.1";
  setupSnmpInterfaceDatabase(m_db, ipAddress, null);
  LatencyThresholdingSet thresholdingSet = new LatencyThresholdingSet(1, ipAddress, "HTTP", null, getRepository(), m_resourceStorageDao);
  assertTrue(thresholdingSet.hasThresholds()); // Global Test
  Map<String, Double> attributes = new HashMap<String, Double>();
  attributes.put("http", 200.0);
  assertTrue(thresholdingSet.hasThresholds(attributes)); // Datasource Test
  List<Event> triggerEvents = new ArrayList<>();
  for (int i=0; i<5; i++)
    triggerEvents.addAll(thresholdingSet.applyThresholds("http", attributes));
  assertTrue(triggerEvents.size() == 1);
  addEvent(EventConstants.HIGH_THRESHOLD_EVENT_UEI, "127.0.0.1", "HTTP", 5, 100.0, 50.0, 200.0, IfLabel.NO_IFLABEL, "127.0.0.1[http]", "http", IfLabel.NO_IFLABEL, null, m_eventIpcManager.getEventAnticipator(), m_anticipatedEvents);
  ThresholdingEventProxy proxy = new ThresholdingEventProxy();
  proxy.add(triggerEvents);
  proxy.sendAllEvents();
  verifyEvents(0);
}
origin: OpenNMS/opennms

/**
 * <p>send</p>
 *
 * @param eventLog a {@link org.opennms.netmgt.xml.event.Log} object.
 * @throws org.opennms.netmgt.events.api.EventProxyException if any.
 */
@Override
public void send(Log eventLog) throws EventProxyException {
  for (Event e : eventLog.getEvents().getEventCollection()) {
    add(e);
  }
}

origin: OpenNMS/opennms

@Test
@JUnitTemporaryDatabase(tempDbClass=MockDatabase.class)
public void testBug3575() throws Exception {
  initFactories("/threshd-configuration-bug3575.xml","/test-thresholds-bug3575.xml");
  String ipAddress = "127.0.0.1";
  String ifName = "eth0";
  setupSnmpInterfaceDatabase(m_db, ipAddress, ifName);
  LatencyThresholdingSet thresholdingSet = new LatencyThresholdingSet(1, ipAddress, "StrafePing", null, getRepository(), m_resourceStorageDao);
  assertTrue(thresholdingSet.hasThresholds());
  Map<String, Double> attributes = new HashMap<String, Double>();
  for (double i=1; i<21; i++) {
    attributes.put("ping" + i, 2 * i);
  }
  attributes.put("loss", 60.0);
  attributes.put("median", 100.0);
  attributes.put(PollStatus.PROPERTY_RESPONSE_TIME, 100.0);
  assertTrue(thresholdingSet.hasThresholds(attributes));
  List<Event> triggerEvents = thresholdingSet.applyThresholds("StrafePing", attributes);
  assertTrue(triggerEvents.size() == 1);
  addEvent(EventConstants.HIGH_THRESHOLD_EVENT_UEI, "127.0.0.1", "StrafePing", 1, 50.0, 25.0, 60.0, ifName, "127.0.0.1[StrafePing]", "loss", "eth0", null, m_eventIpcManager.getEventAnticipator(), m_anticipatedEvents);
  ThresholdingEventProxy proxy = new ThresholdingEventProxy();
  proxy.add(triggerEvents);
  proxy.sendAllEvents();
  verifyEvents(0);
}
origin: OpenNMS/opennms

private void sendRearmForTriggeredStates() {
  for (String instance : m_thresholdEvaluatorStates.keySet()) {
    for (ThresholdEvaluatorState state : m_thresholdEvaluatorStates.get(instance)) {
      if (state.isTriggered()) {
        Event e = state.getEventForState(Status.RE_ARMED, new Date(), Double.NaN, null);
        Parm p = new Parm();
        p.setParmName("reason");
        Value v = new Value();
        v.setContent("Configuration has been changed");
        p.setValue(v);
        e.addParm(p);
        LOG.info("sendRearmForTriggeredStates: sending rearm for {}", e);
        ThresholdingEventProxyFactory.getFactory().getProxy().add(e);
        state.clearState();
      }
    }
  }
}
origin: OpenNMS/opennms

ThresholdingEventProxy proxy = new ThresholdingEventProxy();
proxy.add(triggerEvents);
proxy.add(rearmEvents);
proxy.sendAllEvents();
verifyEvents(0);
org.opennms.netmgt.threshdThresholdingEventProxy

Javadoc

ThresholdingEventProxy class.

Most used methods

  • <init>
    Constructor for ThresholdingEventProxy.
  • add
    add
  • sendAllEvents
    sendAllEvents
  • removeAllEvents
    removeAllEvents

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)