예제 #1
0
  /**
   * {@inheritDoc}
   *
   * <p>This method is invoked by the event manager when a new event is available for processing.
   * Each message is examined for its Universal Event Identifier and the appropriate action is
   * taking based on each UEI.
   */
  @Override
  public void onEvent(Event event) {

    LOG.debug("onEvent: received event, UEI = {}", event.getUei());
    EventBuilder ebldr = null;

    if (isReloadConfigEvent(event)) {
      LOG.info(
          "onEvent: Reloading events configuration in response to event with UEI "
              + event.getUei());
      try {
        m_eventConfDao.reload();
        ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName());
        ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Eventd");

      } catch (Throwable e) {
        LOG.error("onEvent: Could not reload events config", e);
        ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName());
        ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Eventd");
        ebldr.addParam(EventConstants.PARM_REASON, e.getLocalizedMessage().substring(0, 128));
      }

      if (ebldr != null) {
        m_eventIpcManager.sendNow(ebldr.getEvent());
      }
    }
  }
예제 #2
0
  @Test
  public void testNoAlarmData() throws Exception {
    EventBuilder bldr = new EventBuilder("testNoAlarmData", "AlarmdTest");
    bldr.setLogMessage(null);

    m_alarmd.getPersister().persist(bldr.getEvent());
  }
  /** {@inheritDoc} */
  @Override
  public void importProvisioningGroup(final String requisitionName) {
    m_writeLock.lock();

    try {
      final Requisition requisition = getProvisioningGroup(requisitionName);
      saveProvisioningGroup(requisitionName, requisition);

      // then we send an event to the importer
      final EventProxy proxy = Util.createEventProxy();

      m_pendingForeignSourceRepository.flush();
      final String url =
          m_pendingForeignSourceRepository.getRequisitionURL(requisitionName).toString();
      Assert.notNull(url, "Could not find url for group " + requisitionName + ".  Does it exists?");

      final EventBuilder bldr = new EventBuilder(EventConstants.RELOAD_IMPORT_UEI, "Web");
      bldr.addParam(EventConstants.PARM_URL, url);

      try {
        proxy.send(bldr.getEvent());
      } catch (final EventProxyException e) {
        throw new DataAccessResourceFailureException(
            "Unable to send event to import group " + requisitionName, e);
      }
    } finally {
      m_writeLock.unlock();
    }
  }
예제 #4
0
  /**
   * Send a newSuspect event for the interface construct event with 'linkd' as source
   *
   * @param ipInterface The interface for which the newSuspect event is to be generated
   * @param ipowner The host that hold this ipInterface information
   * @pkgName The package Name of the ready runnable involved
   */
  void sendNewSuspectEvent(InetAddress ipaddress, InetAddress ipowner, String pkgName) {

    if (m_newSuspectEventsIpAddr.contains(ipaddress)) {
      LogUtils.infof(
          this,
          "sendNewSuspectEvent: nothing to send, suspect event previously sent for IP address: %s",
          str(ipaddress));
      return;
    } else if (!isInterfaceInPackageRange(ipaddress, pkgName)) {
      LogUtils.infof(
          this,
          "sendNewSuspectEvent: nothing to send for IP address: %s, not in package: %s",
          str(ipaddress),
          pkgName);
      return;
    }

    org.opennms.netmgt.config.linkd.Package pkg = m_linkdConfig.getPackage(pkgName);

    boolean autodiscovery = false;
    if (pkg.hasAutoDiscovery()) autodiscovery = pkg.getAutoDiscovery();
    else autodiscovery = m_linkdConfig.isAutoDiscoveryEnabled();

    if (autodiscovery) {

      EventBuilder bldr = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "linkd");

      bldr.setHost(str(ipowner));
      bldr.setInterface(ipaddress);

      m_eventForwarder.sendNow(bldr.getEvent());

      m_newSuspectEventsIpAddr.add(ipaddress);
    }
  }
예제 #5
0
  /**
   * sendEvent
   *
   * @param uei a {@link java.lang.String} object.
   */
  protected void sendEvent(String uei) {
    EventBuilder bldr = new EventBuilder(uei, "NotifdConfigFactory");

    try {
      EventIpcManagerFactory.getIpcManager().sendNow(bldr.getEvent());
    } catch (Throwable t) {
    }
  }
예제 #6
0
 /**
  * scanCompleted
  *
  * @param currentPhase a {@link org.opennms.core.tasks.BatchTask} object.
  */
 public void scanCompleted(final BatchTask currentPhase) {
   if (!isAborted()) {
     final EventBuilder bldr =
         new EventBuilder(EventConstants.PROVISION_SCAN_COMPLETE_UEI, "Provisiond");
     bldr.setNodeid(getNodeId());
     bldr.addParam(EventConstants.PARM_FOREIGN_SOURCE, getForeignSource());
     bldr.addParam(EventConstants.PARM_FOREIGN_ID, getForeignId());
     getEventForwarder().sendNow(bldr.getEvent());
   }
 }
예제 #7
0
  private EventBuilder createConfigureSnmpEventBuilder(final String firstIp, final String lastIp) {

    EventBuilder bldr =
        new EventBuilder(EventConstants.CONFIGURE_SNMP_EVENT_UEI, "ConfigureSnmpTest");

    bldr.addParam(EventConstants.PARM_FIRST_IP_ADDRESS, firstIp);
    bldr.addParam(EventConstants.PARM_LAST_IP_ADDRESS, lastIp);

    return bldr;
  }
예제 #8
0
 void completed() {
   if (!isAborted()) {
     final EventBuilder bldr =
         new EventBuilder(
             EventConstants.REINITIALIZE_PRIMARY_SNMP_INTERFACE_EVENT_UEI, "Provisiond");
     bldr.setNodeid(getNodeId());
     bldr.setInterface(getAgentAddress());
     getEventForwarder().sendNow(bldr.getEvent());
   }
 }
  private void sendEvent(List<String> filesToPromote) {

    EventBuilder bldr = new EventBuilder(EventConstants.PROMOTE_QUEUE_DATA_UEI, "OpenNMS.Webapp");
    bldr.addParam(EventConstants.PARM_FILES_TO_PROMOTE, filesToPromote);

    try {
      m_eventProxy.send(bldr.getEvent());
    } catch (EventProxyException e) {
      LOG.warn("Unable to send promotion event to opennms daemon", e);
    }
  }
예제 #10
0
  /**
   * Test method for {@link
   * org.opennms.netmgt.config.SnmpPeerFactory#createSnmpEventInfo(org.opennms.netmgt.xml.event.Event)}.
   * Tests creating an SNMP config definition from a configureSNMP event.
   *
   * @throws UnknownHostException
   */
  public void testCreateSnmpEventInfo() throws UnknownHostException {
    EventBuilder bldr = createConfigureSnmpEventBuilder("192.168.1.1", null);
    addCommunityStringToEvent(bldr, "seemore");

    SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());

    assertNotNull(info);
    assertEquals("192.168.1.1", info.getFirstIPAddress());
    assertNull(info.getLastIPAddress());
    assertTrue(info.isSpecific());
  }
예제 #11
0
  /**
   * Tests getting the correct SNMP Peer after a configureSNMP event and merge to the running
   * config.
   *
   * @throws UnknownHostException
   */
  public void testSnmpEventInfoClassWithSpecific() throws UnknownHostException {
    final String addr = "192.168.0.5";
    EventBuilder bldr = createConfigureSnmpEventBuilder(addr, null);
    addCommunityStringToEvent(bldr, "abc");
    SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());

    SnmpPeerFactory.getInstance().define(info);

    SnmpAgentConfig agent =
        SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr));
    assertEquals(InetAddressUtils.str(agent.getAddress()), addr);
    assertEquals("abc", agent.getReadCommunity());
  }
예제 #12
0
  /**
   * sendLabelChangeEvent
   *
   * @param nodeId a int.
   * @param oldNodeLabel a {@link org.opennms.netmgt.utils.NodeLabelJDBCImpl} object.
   * @param newNodeLabel a {@link org.opennms.netmgt.utils.NodeLabelJDBCImpl} object.
   * @throws org.opennms.netmgt.model.events.EventProxyException if any.
   */
  protected void sendLabelChangeEvent(
      int nodeId, NodeLabelJDBCImpl oldNodeLabel, NodeLabelJDBCImpl newNodeLabel)
      throws EventProxyException {

    EventBuilder bldr =
        new EventBuilder(EventConstants.NODE_LABEL_CHANGED_EVENT_UEI, "NodeLabelChangeServlet");

    bldr.setNodeid(nodeId);
    bldr.setHost("host");

    if (oldNodeLabel != null) {
      bldr.addParam(EventConstants.PARM_OLD_NODE_LABEL, oldNodeLabel.getLabel());
      if (oldNodeLabel.getSource() != null) {
        bldr.addParam(
            EventConstants.PARM_OLD_NODE_LABEL_SOURCE, oldNodeLabel.getSource().toString());
      }
    }

    if (newNodeLabel != null) {
      bldr.addParam(EventConstants.PARM_NEW_NODE_LABEL, newNodeLabel.getLabel());
      if (newNodeLabel.getSource() != null) {
        bldr.addParam(
            EventConstants.PARM_NEW_NODE_LABEL_SOURCE, newNodeLabel.getSource().toString());
      }
    }

    this.proxy.send(bldr.getEvent());
  }
예제 #13
0
  @Test
  public void testNoLogmsg() throws Exception {
    EventBuilder bldr = new EventBuilder("testNoLogmsg", "AlarmdTest");
    bldr.setAlarmData(new AlarmData());

    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalArgumentException("Incoming event has an illegal dbid (0), aborting"));
    try {
      m_alarmd.getPersister().persist(bldr.getEvent());
    } catch (Throwable t) {
      ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
  }
예제 #14
0
  private void sendNodeDownEventWithUpdateFieldSeverity(
      String reductionKey, MockNode node, OnmsSeverity severity) throws SQLException {
    EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);

    if (reductionKey != null) {
      AlarmData data = new AlarmData();
      data.setAlarmType(1);
      data.setReductionKey(reductionKey);

      List<UpdateField> fields = new ArrayList<UpdateField>();

      UpdateField field = new UpdateField();
      field.setFieldName("Severity");
      field.setUpdateOnReduction(Boolean.TRUE);
      fields.add(field);

      data.setUpdateField(fields);

      event.setAlarmData(data);
    } else {
      event.setAlarmData(null);
    }

    event.setLogDest("logndisplay");
    event.setLogMessage("testing");

    event.setSeverity(severity.getLabel());

    m_eventdIpcMgr.sendNow(event.getEvent());
  }
예제 #15
0
  /**
   * Tests getting the correct SNMP Peer after receiving a configureSNMP event that moves a specific
   * from one definition into another.
   *
   * @throws UnknownHostException
   */
  public void testSplicingSpecificsIntoRanges() throws UnknownHostException {
    assertEquals(3, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getRangeCount());
    assertEquals(6, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getSpecificCount());

    final String specificAddr = "10.1.1.7";
    final EventBuilder bldr = createConfigureSnmpEventBuilder(specificAddr, null);
    final SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
    info.setCommunityString("splice-test");
    info.setVersion("v2c");

    SnmpPeerFactory.getInstance().define(info);

    assertEquals(5, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getRangeCount());

    assertEquals("10.1.1.10", SnmpPeerFactory.getSnmpConfig().getDefinition(2).getSpecific(0));
    assertEquals(1, SnmpPeerFactory.getSnmpConfig().getDefinition(2).getSpecificCount());
    assertEquals(m_startingDefCount, SnmpPeerFactory.getSnmpConfig().getDefinitionCount());
  }
예제 #16
0
  public void importRequisition(final String foreignSource, final Boolean rescanExisting) {
    final URL activeUrl = createSnapshot(foreignSource);

    final String url = activeUrl.toString();
    LOG.debug("importRequisition: Sending import event with URL {}", url);
    final EventBuilder bldr = new EventBuilder(EventConstants.RELOAD_IMPORT_UEI, "Web");
    bldr.addParam(EventConstants.PARM_URL, url);
    if (rescanExisting != null) {
      bldr.addParam(EventConstants.PARM_IMPORT_RESCAN_EXISTING, rescanExisting);
    }

    try {
      getEventProxy().send(bldr.getEvent());
    } catch (final EventProxyException e) {
      throw new DataAccessResourceFailureException(
          "Unable to send event to import group " + foreignSource, e);
    }
  }
  private void sendEvent(EventProxy proxy, long count) throws Exception {
    EventBuilder bldr =
        new EventBuilder(
            "uei.opennms.org/internal/authentication/successfulLogin", "MemoryLeakTest");
    bldr.addParam("user", "brozow");

    proxy.send(bldr.getEvent());

    long free = Runtime.getRuntime().freeMemory();
    long max = Runtime.getRuntime().maxMemory();

    double pct = ((double) free) / ((double) max);
    System.err.println("% Free Memory is " + pct);

    if (pct < 0.01) {
      throw new IllegalStateException("Memory Used up!");
    }
  }
예제 #18
0
  /**
   * This test should remove the specific 192.168.0.5 from the first definition and replace it with
   * a range 192.168.0.5 - 192.168.0.7.
   *
   * @throws UnknownHostException
   */
  public void testSnmpEventInfoClassWithRangeReplacingSpecific() throws UnknownHostException {
    final String addr1 = "192.168.0.5";
    final String addr2 = "192.168.0.7";

    SnmpAgentConfig agent =
        SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr1));
    assertEquals(SnmpAgentConfig.VERSION2C, agent.getVersion());

    EventBuilder bldr = createConfigureSnmpEventBuilder(addr1, addr2);
    SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
    info.setVersion("v2c");

    SnmpPeerFactory.getInstance().define(info);

    agent = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr1));
    assertEquals(InetAddressUtils.str(agent.getAddress()), addr1);
    assertEquals(SnmpAgentConfig.VERSION2C, agent.getVersion());
    assertEquals(m_startingDefCount, SnmpPeerFactory.getSnmpConfig().getDefinitionCount());
  }
예제 #19
0
  /**
   * Tests getting the correct SNMP Peer after merging a new range that super sets a current range.
   *
   * @throws UnknownHostException
   */
  public void testSnmpEventInfoClassWithRangeSuperSettingDefRanges() throws UnknownHostException {
    final String addr1 = "192.168.99.1";
    final String addr2 = "192.168.108.254";

    SnmpAgentConfig agent =
        SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr1));
    assertEquals(SnmpAgentConfig.VERSION1, agent.getVersion());

    EventBuilder bldr = createConfigureSnmpEventBuilder(addr1, addr2);
    SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
    info.setCommunityString("opennmsrules");

    SnmpPeerFactory.getInstance().define(info);

    agent = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(addr1));
    assertEquals(InetAddressUtils.str(agent.getAddress()), addr1);
    assertEquals(SnmpAgentConfig.VERSION1, agent.getVersion());
    assertEquals(m_startingDefCount, SnmpPeerFactory.getSnmpConfig().getDefinitionCount());
  }
  @Test
  public void dwoDataLinkFailedEventEndPoint1() {

    expect(m_nodeLinkService.getNodeId(END_POINT_1)).andStubReturn(1);
    expect(m_nodeLinkService.getNodeId(END_POINT_2)).andStubReturn(2);

    m_nodeLinkService.updateLinkStatus(1, 2, FAILED_STATUS);

    replay();

    EventBuilder eventBuilder = new EventBuilder(EventConstants.DATA_LINK_FAILED_EVENT_UEI, null);
    eventBuilder.setParam("endPoint1", END_POINT_1);
    eventBuilder.setParam("endPoint2", END_POINT_2);

    m_adapter.setLinkMatchResolver(m_matchResolver);
    m_adapter.setNodeLinkService(m_nodeLinkService);
    m_adapter.dataLinkFailed(eventBuilder.getEvent());

    verify();
  }
예제 #21
0
  @Test
  @JUnitTemporaryDatabase(
      tempDbClass = MockDatabase.class) // Relies on specific IDs so we need a fresh database
  public void testNorthbounder() throws Exception {
    assertTrue(m_northbounder.isInitialized());
    assertTrue(m_northbounder.getAlarms().isEmpty());

    final EventBuilder bldr = new EventBuilder("testNoLogmsg", "AlarmdTest");
    bldr.setAlarmData(new AlarmData());
    bldr.setLogMessage("This is a test.");

    final Event event = bldr.getEvent();
    event.setDbid(17);

    MockNode node = m_mockNetwork.getNode(1);
    sendNodeDownEvent("%nodeid%", node);

    final List<NorthboundAlarm> alarms = m_northbounder.getAlarms();
    assertTrue(alarms.size() > 0);
  }
예제 #22
0
  private void sendNodeDownEventChangeLogMsg(String reductionKey, MockNode node, String logMsg) {

    EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);

    if (reductionKey != null) {
      AlarmData data = new AlarmData();
      data.setAlarmType(1);
      data.setReductionKey(reductionKey);

      List<UpdateField> fields = new ArrayList<UpdateField>();

      UpdateField field = new UpdateField();
      field.setFieldName("logMsg");
      field.setUpdateOnReduction(Boolean.TRUE);
      fields.add(field);

      data.setUpdateField(fields);

      event.setAlarmData(data);
    } else {
      event.setAlarmData(null);
    }

    event.setLogDest("logndisplay");
    event.setLogMessage(logMsg);

    m_eventdIpcMgr.sendNow(event.getEvent());
  }
 /**
  * handleReloadConfigEvent
  *
  * @param event a {@link org.opennms.netmgt.xml.event.Event} object.
  */
 @EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI)
 public void handleReloadConfigEvent(final Event event) {
   if (isReloadConfigEventTarget(event)) {
     EventBuilder ebldr = null;
     LogUtils.debugf(this, "Reloading the SNMP asset adapter configuration");
     try {
       m_config.update();
       ebldr =
           new EventBuilder(
               EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, "Provisiond." + NAME);
       ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Provisiond." + NAME);
     } catch (Throwable e) {
       LogUtils.infof(this, e, "Unable to reload SNMP asset adapter configuration");
       ebldr =
           new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_FAILED_UEI, "Provisiond." + NAME);
       ebldr.addParam(EventConstants.PARM_DAEMON_NAME, "Provisiond." + NAME);
       ebldr.addParam(EventConstants.PARM_REASON, e.getLocalizedMessage().substring(1, 128));
     }
     if (ebldr != null) {
       getEventForwarder().sendNow(ebldr.getEvent());
     }
   }
 }
예제 #24
0
  /**
   * This test should show that a specific is added to the definition and the current single
   * definition should become the beginning address in the adjacent range.
   *
   * @throws UnknownHostException
   */
  public void testSplice2() throws UnknownHostException {
    assertEquals(3, SnmpPeerFactory.getSnmpConfig().getDefinition(3).getRangeCount());
    assertEquals(1, SnmpPeerFactory.getSnmpConfig().getDefinition(3).getSpecificCount());
    assertEquals("10.1.1.10", SnmpPeerFactory.getSnmpConfig().getDefinition(3).getSpecific(0));
    assertEquals(
        "10.1.1.11", SnmpPeerFactory.getSnmpConfig().getDefinition(3).getRange(0).getBegin());

    final String specificAddr = "10.1.1.7";
    final EventBuilder bldr = createConfigureSnmpEventBuilder(specificAddr, null);
    final SnmpEventInfo info = new SnmpEventInfo(bldr.getEvent());
    info.setCommunityString("splice2-test");

    SnmpPeerFactory.getInstance().define(info);

    assertEquals(3, SnmpPeerFactory.getSnmpConfig().getDefinition(3).getRangeCount());
    assertEquals(1, SnmpPeerFactory.getSnmpConfig().getDefinition(3).getSpecificCount());
    assertEquals("10.1.1.7", SnmpPeerFactory.getSnmpConfig().getDefinition(3).getSpecific(0));
    assertEquals(
        "10.1.1.10", SnmpPeerFactory.getSnmpConfig().getDefinition(3).getRange(0).getBegin());

    String marshalledConfig = SnmpPeerFactory.marshallConfig();
    assertNotNull(marshalledConfig);
  }
  public void testAuthenticationSuccessEventWithEverything() throws Exception {
    String userName = "******";
    String ip = "1.2.3.4";
    String sessionId = "it tastes just like our regular coffee";

    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpSession session = createMock(HttpSession.class);
    expect(request.getRemoteAddr()).andReturn(ip);
    expect(request.getSession(false)).andReturn(session);
    expect(session.getId()).andReturn(sessionId);

    replay(request, session);
    WebAuthenticationDetails details = new WebAuthenticationDetails(request);
    verify(request, session);

    org.springframework.security.core.Authentication authentication =
        new TestingDetailsAuthenticationToken(
            userName, "cheesiness", new GrantedAuthority[0], details);
    AuthenticationSuccessEvent authEvent = new AuthenticationSuccessEvent(authentication);

    SecurityAuthenticationEventOnmsEventBuilder builder =
        new SecurityAuthenticationEventOnmsEventBuilder();
    builder.setEventProxy(m_eventProxy);
    builder.afterPropertiesSet();

    EventBuilder eventBuilder =
        new EventBuilder(SecurityAuthenticationEventOnmsEventBuilder.SUCCESS_UEI, "OpenNMS.WebUI");
    eventBuilder.addParam("user", userName);
    eventBuilder.addParam("ip", ip);

    m_eventProxy.send(EventEquals.eqEvent(eventBuilder.getEvent()));

    m_mocks.replayAll();
    builder.onApplicationEvent(authEvent);
    m_mocks.verifyAll();
  }
  /** {@inheritDoc} */
  public void poll(OnmsMonitoredService monSvc, int pollResultId) {

    EventBuilder bldr =
        new EventBuilder(EventConstants.DEMAND_POLL_SERVICE_EVENT_UEI, "PollerService");

    bldr.setNodeid(monSvc.getNodeId());
    bldr.setInterface(monSvc.getIpAddress());
    bldr.setIfIndex(monSvc.getIfIndex());
    bldr.setService(monSvc.getServiceType().getName());

    bldr.addParam(EventConstants.PARM_DEMAND_POLL_ID, pollResultId);

    sendEvent(bldr.getEvent());
  }
예제 #27
0
  /**
   * abort
   *
   * @param reason a {@link java.lang.String} object.
   */
  public void abort(final String reason) {
    m_aborted = true;

    LOG.info("Aborting Scan of node {} for the following reason: {}", m_nodeId, reason);

    final EventBuilder bldr =
        new EventBuilder(EventConstants.PROVISION_SCAN_ABORTED_UEI, "Provisiond");
    if (m_nodeId != null) {
      bldr.setNodeid(m_nodeId);
    }
    bldr.addParam(EventConstants.PARM_FOREIGN_SOURCE, m_foreignSource);
    bldr.addParam(EventConstants.PARM_FOREIGN_ID, m_foreignId);
    bldr.addParam(EventConstants.PARM_REASON, reason);

    m_eventForwarder.sendNow(bldr.getEvent());
  }
예제 #28
0
  private void sendNodeDownEvent(String reductionKey, MockNode node) throws SQLException {
    EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);

    if (reductionKey != null) {
      AlarmData data = new AlarmData();
      data.setAlarmType(1);
      data.setReductionKey(reductionKey);
      event.setAlarmData(data);
    } else {
      event.setAlarmData(null);
    }

    event.setLogDest("logndisplay");
    event.setLogMessage("testing");

    m_eventdIpcMgr.sendNow(event.getEvent());
  }
예제 #29
0
  private void sendNewSuspectEvent(InetAddress address, Long rtt, String foreignSource) {
    EventBuilder eb =
        new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "OpenNMS.Discovery");
    eb.setInterface(address);
    eb.setHost(InetAddressUtils.getLocalHostName());

    eb.addParam("RTT", rtt);

    if (foreignSource != null) {
      eb.addParam("foreignSource", foreignSource);
    }

    try {
      m_ipc_manager.sendNow(eb.getEvent());
      LOG.debug("Sent event: {}", EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI);
    } catch (Throwable t) {
      LOG.warn("run: unexpected throwable exception caught during send to middleware", t);
    }
  }
예제 #30
0
 private void addCommunityStringToEvent(final EventBuilder bldr, final String commStr) {
   bldr.addParam(EventConstants.PARM_COMMUNITY_STRING, commStr);
 }