Search in sources :

Example 6 with AlarmData

use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.

the class MockEventUtil method createNodeDownEventBuilder.

/**
     * <p>createNodeDownEventBuilder</p>
     *
     * @param source a {@link java.lang.String} object.
     * @param node a {@link org.opennms.netmgt.mock.MockNode} object.
     * @return a {@link org.opennms.netmgt.model.events.EventBuilder} object.
     */
public static EventBuilder createNodeDownEventBuilder(String source, OnmsNode node) {
    EventBuilder event = createNodeEventBuilder(source, EventConstants.NODE_DOWN_EVENT_UEI, node);
    event.setSeverity(OnmsSeverity.MAJOR.getLabel());
    // <alarm-data reduction-key="%uei%:%dpname%:%nodeid%" alarm-type="1" auto-clean="false" />
    AlarmData alarmData = new AlarmData();
    alarmData.setReductionKey("%uei%:%dpname%:%nodeid%");
    alarmData.setAlarmType(1);
    alarmData.setAutoClean(false);
    event.setAlarmData(alarmData);
    return event;
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) AlarmData(org.opennms.netmgt.xml.event.AlarmData)

Example 7 with AlarmData

use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.

the class AlarmLifecycleEventsIT method sendNodeDownEvent.

private void sendNodeDownEvent(long nodeId) {
    EventBuilder builder = new EventBuilder(EventConstants.NODE_DOWN_EVENT_UEI, "test");
    Date currentTime = new Date();
    builder.setTime(currentTime);
    builder.setNodeid(nodeId);
    builder.setSeverity("Major");
    AlarmData data = new AlarmData();
    data.setAlarmType(1);
    data.setReductionKey(String.format("%s:%d", EventConstants.NODE_DOWN_EVENT_UEI, nodeId));
    builder.setAlarmData(data);
    builder.setLogDest("logndisplay");
    builder.setLogMessage("testing");
    m_eventMgr.sendNow(builder.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) Date(java.util.Date) AlarmData(org.opennms.netmgt.xml.event.AlarmData)

Example 8 with AlarmData

use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.

the class AlarmdIT method sendNodeDownEventWithUpdateFieldSeverity.

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());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) UpdateField(org.opennms.netmgt.xml.event.UpdateField) ArrayList(java.util.ArrayList) AlarmData(org.opennms.netmgt.xml.event.AlarmData)

Example 9 with AlarmData

use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.

the class AlarmdIT method testNoLogmsg.

@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();
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) AlarmData(org.opennms.netmgt.xml.event.AlarmData) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 10 with AlarmData

use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.

the class AlarmdIT method sendNodeDownEventDontChangeLogMsg.

//Supporting method for test
private void sendNodeDownEventDontChangeLogMsg(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.FALSE);
        fields.add(field);
        data.setUpdateField(fields);
        event.setAlarmData(data);
    } else {
        event.setAlarmData(null);
    }
    event.setLogDest("logndisplay");
    event.setLogMessage(logMsg);
    m_eventdIpcMgr.sendNow(event.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) UpdateField(org.opennms.netmgt.xml.event.UpdateField) ArrayList(java.util.ArrayList) AlarmData(org.opennms.netmgt.xml.event.AlarmData)

Aggregations

AlarmData (org.opennms.netmgt.xml.event.AlarmData)19 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)14 Event (org.opennms.netmgt.xml.event.Event)6 ArrayList (java.util.ArrayList)5 UpdateField (org.opennms.netmgt.xml.event.UpdateField)5 Date (java.util.Date)3 Test (org.junit.Test)3 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)2 Logmsg (org.opennms.netmgt.xml.event.Logmsg)2 Parm (org.opennms.netmgt.xml.event.Parm)2 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)2 InetAddress (java.net.InetAddress)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ObjectNotFoundException (org.hibernate.ObjectNotFoundException)1 Before (org.junit.Before)1 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)1 MockNode (org.opennms.netmgt.mock.MockNode)1 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)1 Value (org.opennms.netmgt.xml.event.Value)1