Search in sources :

Example 76 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class AlarmHopCriteria method createVertices.

private Set<VertexRef> createVertices(List<OnmsAlarm> alarms) {
    Set<VertexRef> vertices = new TreeSet<VertexRef>(new RefComparator());
    for (OnmsAlarm alarm : alarms) {
        OnmsNode node = alarm.getNode();
        if (node == null) {
            continue;
        }
        vertices.add(new DefaultVertexRef("nodes", String.valueOf(node.getId()), node.getLabel()));
    }
    return vertices;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) TreeSet(java.util.TreeSet) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) DefaultVertexRef(org.opennms.features.topology.api.topo.DefaultVertexRef) VertexRef(org.opennms.features.topology.api.topo.VertexRef) RefComparator(org.opennms.features.topology.api.topo.RefComparator)

Example 77 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class AlarmStatusCalculatorIT method verifyCalculateStatus.

@Test
@Transactional
public void verifyCalculateStatus() {
    final OnmsNode node = databasePopulator.getNode1();
    final GeolocationQuery query = new GeolocationQueryBuilder().build();
    final StatusCalculator statusCalculator = new AlarmStatusCalculator(genericPersistenceAccessor);
    final Set<Integer> nodeIds = Sets.newHashSet(node.getId());
    // No alarm exists, status should be normal
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
    // Create an alarm and verify status
    OnmsAlarm alarm = createAlarm(node, OnmsSeverity.WARNING);
    alarmDao.save(alarm);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.WARNING), statusCalculator.calculateStatus(query, nodeIds));
    // Create an alarm for same node and verify
    OnmsAlarm alarm2 = createAlarm(node, OnmsSeverity.MINOR);
    alarmDao.save(alarm2);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    // Create an alarm for another node and verify
    alarmDao.save(createAlarm(databasePopulator.getNode2(), OnmsSeverity.CRITICAL));
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    // Acknowledge alarms
    alarm2.setAlarmAckTime(new Date());
    alarm2.setAlarmAckUser("ulf");
    alarmDao.saveOrUpdate(alarm2);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.WARNING), statusCalculator.calculateStatus(query, nodeIds));
    alarm.setAlarmAckTime(new Date());
    alarm.setAlarmAckUser("ulf");
    alarmDao.saveOrUpdate(alarm);
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
    // Include acknowledged alarms
    query.setIncludeAcknowledgedAlarms(true);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    // Apply severity filter
    query.setSeverity(GeolocationSeverity.Warning);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setSeverity(GeolocationSeverity.Minor);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setSeverity(GeolocationSeverity.Major);
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
    // reset severity filter and apply location filter
    query.setSeverity(null);
    query.setLocation(distPollerDao.whoami().getLocation());
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setLocation("XXX");
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) GeolocationQueryBuilder(org.opennms.features.geolocation.api.GeolocationQueryBuilder) GeolocationQuery(org.opennms.features.geolocation.api.GeolocationQuery) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 78 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class DroolsTicketerServiceLayerTest method expectNewAlarmState.

private void expectNewAlarmState(final TroubleTicketState state) {
    m_alarmDao.saveOrUpdate(m_alarm);
    EasyMock.expectLastCall().andAnswer(() -> {
        OnmsAlarm alarm = (OnmsAlarm) EasyMock.getCurrentArguments()[0];
        assertEquals(state, alarm.getTTicketState());
        return null;
    });
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm)

Example 79 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class DefaultTicketerServiceLayerTest method setUp.

@Before
public void setUp() throws Exception {
    System.clearProperty(DefaultTicketerServiceLayer.SKIP_CREATE_WHEN_CLEARED_SYS_PROP);
    System.clearProperty(DefaultTicketerServiceLayer.SKIP_CLOSE_WHEN_NOT_CLEARED_SYS_PROP);
    m_eventIpcManager = new MockEventIpcManager();
    EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
    MockLogAppender.setupLogging();
    m_defaultTicketerServiceLayer = new DefaultTicketerServiceLayer();
    m_easyMockUtils = new EasyMockUtils();
    m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
    m_defaultTicketerServiceLayer.setAlarmDao(m_alarmDao);
    m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
    m_defaultTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
    m_alarm = new OnmsAlarm();
    m_alarm.setId(1);
    m_alarm.setLogMsg("Test Logmsg");
    m_alarm.setDescription("Test Description");
    m_ticket = new Ticket();
    m_ticket.setId("4");
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) Plugin(org.opennms.api.integration.ticketing.Plugin) Before(org.junit.Before)

Example 80 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method createCloudDownAlarm.

private List<OnmsAlarm> createCloudDownAlarm() {
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setNode(m_node1);
    alarm.setIfIndex(48);
    alarm.setUei(EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI);
    return Arrays.asList(alarm);
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm)

Aggregations

OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)143 Test (org.junit.Test)58 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)41 Date (java.util.Date)36 OnmsNode (org.opennms.netmgt.model.OnmsNode)36 Transactional (org.springframework.transaction.annotation.Transactional)35 OnmsEventParameter (org.opennms.netmgt.model.OnmsEventParameter)19 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)18 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)18 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)17 ArrayList (java.util.ArrayList)14 OnmsAcknowledgment (org.opennms.netmgt.model.OnmsAcknowledgment)14 InetAddress (java.net.InetAddress)13 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)11 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)10 OnmsNotification (org.opennms.netmgt.model.OnmsNotification)9 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)9 AlarmDao (org.opennms.netmgt.dao.api.AlarmDao)8 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)8 LinkedList (java.util.LinkedList)7