Search in sources :

Example 36 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class DeleteNodesServlet method sendDeleteNodeEvent.

private void sendDeleteNodeEvent(int node) throws ServletException {
    EventBuilder bldr = new EventBuilder(EventConstants.DELETE_NODE_EVENT_UEI, "web ui");
    bldr.setNodeid(node);
    bldr.addParam(EventConstants.PARM_TRANSACTION_NO, "webUI");
    sendEvent(bldr.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder)

Example 37 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class TrapdIT method testSnmpV2cTrapSend.

@Test
public void testSnmpV2cTrapSend() throws Exception {
    String localhost = "127.0.0.1";
    InetAddress localAddr = InetAddressUtils.addr(localhost);
    SnmpObjId enterpriseId = SnmpObjId.get(".1.3.6.1.4.1.5813");
    SnmpObjId trapOID = SnmpObjId.get(enterpriseId, new SnmpInstId(1));
    SnmpTrapBuilder pdu = SnmpUtils.getV2TrapBuilder();
    pdu.addVarBind(SnmpObjId.get(".1.3.6.1.2.1.1.3.0"), SnmpUtils.getValueFactory().getTimeTicks(0));
    pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.1.0"), SnmpUtils.getValueFactory().getObjectId(trapOID));
    pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.3.0"), SnmpUtils.getValueFactory().getObjectId(enterpriseId));
    EventBuilder defaultTrapBuilder = new EventBuilder("uei.opennms.org/default/trap", "trapd");
    defaultTrapBuilder.setInterface(localAddr);
    defaultTrapBuilder.setSnmpVersion("v2c");
    m_mockEventIpcManager.getEventAnticipator().anticipateEvent(defaultTrapBuilder.getEvent());
    EventBuilder newSuspectBuilder = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "trapd");
    newSuspectBuilder.setInterface(localAddr);
    m_mockEventIpcManager.getEventAnticipator().anticipateEvent(newSuspectBuilder.getEvent());
    pdu.send(localhost, m_trapdConfig.getSnmpTrapPort(), "public");
    // Allow time for Trapd and Eventd to do their magic
    Thread.sleep(5000);
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) SnmpObjId(org.opennms.netmgt.snmp.SnmpObjId) InetAddress(java.net.InetAddress) SnmpTrapBuilder(org.opennms.netmgt.snmp.SnmpTrapBuilder) Test(org.junit.Test)

Example 38 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class TrapdIT method testSnmpV1TrapSend.

@Test
public void testSnmpV1TrapSend() throws Exception {
    String localhost = "127.0.0.1";
    InetAddress localAddr = InetAddressUtils.addr(localhost);
    SnmpV1TrapBuilder pdu = SnmpUtils.getV1TrapBuilder();
    pdu.setEnterprise(SnmpObjId.get(".1.3.6.1.4.1.5813"));
    pdu.setGeneric(1);
    pdu.setSpecific(0);
    pdu.setTimeStamp(666L);
    pdu.setAgentAddress(localAddr);
    EventBuilder defaultTrapBuilder = new EventBuilder("uei.opennms.org/default/trap", "trapd");
    defaultTrapBuilder.setInterface(localAddr);
    defaultTrapBuilder.setSnmpVersion("v1");
    m_mockEventIpcManager.getEventAnticipator().anticipateEvent(defaultTrapBuilder.getEvent());
    EventBuilder newSuspectBuilder = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "trapd");
    newSuspectBuilder.setInterface(localAddr);
    m_mockEventIpcManager.getEventAnticipator().anticipateEvent(newSuspectBuilder.getEvent());
    pdu.send(localhost, m_trapdConfig.getSnmpTrapPort(), "public");
    // Allow time for Trapd and Eventd to do their magic
    Thread.sleep(5000);
}
Also used : SnmpV1TrapBuilder(org.opennms.netmgt.snmp.SnmpV1TrapBuilder) EventBuilder(org.opennms.netmgt.model.events.EventBuilder) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 39 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class DefaultPollerBackEnd method sendRegainedOrLostServiceEvent.

private void sendRegainedOrLostServiceEvent(final OnmsLocationSpecificStatus newStatus, final PollStatus pollResult) {
    final String uei = pollResult.isAvailable() ? EventConstants.REMOTE_NODE_REGAINED_SERVICE_UEI : EventConstants.REMOTE_NODE_LOST_SERVICE_UEI;
    final EventBuilder builder = createEventBuilder(newStatus.getLocationMonitor(), uei).setMonitoredService(newStatus.getMonitoredService());
    if (!pollResult.isAvailable() && pollResult.getReason() != null) {
        builder.addParam(EventConstants.PARM_LOSTSERVICE_REASON, pollResult.getReason());
    }
    m_eventIpcManager.sendNow(builder.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder)

Example 40 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class PollerBackEndTest method createReconnectedEvent.

private static Event createReconnectedEvent() {
    EventBuilder eventBuilder = new EventBuilder(EventConstants.LOCATION_MONITOR_RECONNECTED_UEI, "PollerBackEnd");
    eventBuilder.addParam(EventConstants.PARM_LOCATION_MONITOR_ID, LOCATION_MONITOR_ID);
    return eventBuilder.getEvent();
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder)

Aggregations

EventBuilder (org.opennms.netmgt.model.events.EventBuilder)305 Test (org.junit.Test)88 Event (org.opennms.netmgt.xml.event.Event)84 Date (java.util.Date)22 OnmsNode (org.opennms.netmgt.model.OnmsNode)17 InetAddress (java.net.InetAddress)16 EventProxyException (org.opennms.netmgt.events.api.EventProxyException)15 AlarmData (org.opennms.netmgt.xml.event.AlarmData)14 EventAnticipator (org.opennms.netmgt.dao.mock.EventAnticipator)12 ServletException (javax.servlet.ServletException)9 EventHandler (org.opennms.netmgt.events.api.annotations.EventHandler)9 Parm (org.opennms.netmgt.xml.event.Parm)9 Event (org.opennms.netmgt.xml.eventconf.Event)9 File (java.io.File)8 ArrayList (java.util.ArrayList)8 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)7 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)7 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)7 SyntaxToEvent (org.opennms.netmgt.model.events.snmp.SyntaxToEvent)7 Transactional (org.springframework.transaction.annotation.Transactional)6