Search in sources :

Example 6 with AlarmSummary

use of org.opennms.netmgt.model.alarm.AlarmSummary in project opennms by OpenNMS.

the class AlarmDaoIT method testAlarmSummary.

@Test
@Transactional
public void testAlarmSummary() {
    OnmsEvent event = new OnmsEvent();
    event.setEventLog("Y");
    event.setEventDisplay("Y");
    event.setEventCreateTime(new Date());
    event.setDistPoller(m_distPollerDao.whoami());
    event.setEventTime(new Date());
    event.setEventSeverity(OnmsSeverity.CRITICAL.getId());
    event.setEventUei("uei://org/opennms/test/EventDaoTest");
    event.setEventSource("test");
    m_eventDao.save(event);
    OnmsNode node = m_nodeDao.findAll().iterator().next();
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setNode(node);
    alarm.setUei(event.getEventUei());
    alarm.setSeverityId(event.getEventSeverity());
    alarm.setFirstEventTime(event.getEventTime());
    alarm.setLastEvent(event);
    alarm.setCounter(1);
    alarm.setDistPoller(m_distPollerDao.whoami());
    m_alarmDao.save(alarm);
    List<AlarmSummary> summary = m_alarmDao.getNodeAlarmSummaries();
    Assert.assertNotNull(summary);
    Assert.assertEquals(1, summary.size());
    AlarmSummary sum = summary.get(0);
    Assert.assertEquals(node.getLabel(), sum.getNodeLabel());
    Assert.assertEquals(alarm.getSeverity().getId(), sum.getMaxSeverity().getId());
    Assert.assertNotSame("N/A", sum.getFuzzyTimeDown());
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with AlarmSummary

use of org.opennms.netmgt.model.alarm.AlarmSummary in project opennms by OpenNMS.

the class VmwareStatusProvider method getStatusForVertices.

@Override
public Map<VertexRef, Status> getStatusForVertices(VertexProvider vertexProvider, Collection<VertexRef> vertices, Criteria[] criteria) {
    final List<AbstractVertex> vmwareVertices = vertices.stream().filter(v -> v.getNamespace().equals(getNamespace())).map(v -> (AbstractVertex) v).collect(Collectors.toList());
    // All vertices associated with a node id
    final Map<Integer, VertexRef> nodeIdMap = vmwareVertices.stream().filter(v -> v.getNodeID() != null).collect(Collectors.toMap(AbstractVertex::getNodeID, Function.identity()));
    // Alarm summary for each node id
    final Map<Integer, AlarmSummary> nodeIdToAlarmSummaryMap = getAlarmSummaries(nodeIdMap.keySet());
    // Set the result
    Map<VertexRef, Status> resultMap = Maps.newHashMap();
    for (AbstractVertex eachVertex : vmwareVertices) {
        AlarmSummary alarmSummary = nodeIdToAlarmSummaryMap.get(eachVertex.getNodeID());
        if (alarmSummary != null) {
            resultMap.put(eachVertex, new DefaultStatus(alarmSummary.getMaxSeverity().getLabel(), 0));
        }
    }
    return resultMap;
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) Collection(java.util.Collection) Set(java.util.Set) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) ArrayList(java.util.ArrayList) Objects(java.util.Objects) DefaultStatus(org.opennms.features.topology.api.topo.DefaultStatus) List(java.util.List) StatusProvider(org.opennms.features.topology.api.topo.StatusProvider) VertexProvider(org.opennms.features.topology.api.topo.VertexProvider) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) Map(java.util.Map) Criteria(org.opennms.features.topology.api.topo.Criteria) Status(org.opennms.features.topology.api.topo.Status) VertexRef(org.opennms.features.topology.api.topo.VertexRef) DefaultStatus(org.opennms.features.topology.api.topo.DefaultStatus) Status(org.opennms.features.topology.api.topo.Status) DefaultStatus(org.opennms.features.topology.api.topo.DefaultStatus) AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 8 with AlarmSummary

use of org.opennms.netmgt.model.alarm.AlarmSummary in project opennms by OpenNMS.

the class AlarmBoxController method handleRequestInternal.

/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    int rows = Integer.getInteger("opennms.nodesWithProblems.count", ROWS);
    final String parm = request.getParameter("alarmCount");
    if (parm != null) {
        try {
            rows = Integer.valueOf(parm);
        } catch (NumberFormatException e) {
        // ignore, and let it fall back to the defaults
        }
    }
    List<AlarmSummary> summaries = m_webAlarmRepository.getCurrentNodeAlarmSummaries();
    int moreCount = summaries.size() - rows;
    ModelAndView modelAndView = new ModelAndView(getSuccessView());
    if (rows == 0 || summaries.size() < rows) {
        modelAndView.addObject("summaries", summaries);
    } else {
        modelAndView.addObject("summaries", summaries.subList(0, rows));
    }
    modelAndView.addObject("moreCount", moreCount);
    return modelAndView;
}
Also used : AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 9 with AlarmSummary

use of org.opennms.netmgt.model.alarm.AlarmSummary in project opennms by OpenNMS.

the class AlarmStatusProvider method getAlarmSummaries.

private Map<Integer, AlarmSummary> getAlarmSummaries(Set<Integer> nodeIds) {
    Map<Integer, AlarmSummary> resultMap = new HashMap<Integer, AlarmSummary>();
    List<AlarmSummary> alarmSummaries = m_alarmDao.getNodeAlarmSummariesIncludeAcknowledgedOnes(new ArrayList<Integer>(nodeIds));
    for (AlarmSummary eachSummary : alarmSummaries) {
        resultMap.put(eachSummary.getNodeId(), eachSummary);
    }
    return resultMap;
}
Also used : HashMap(java.util.HashMap) AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary)

Example 10 with AlarmSummary

use of org.opennms.netmgt.model.alarm.AlarmSummary in project opennms by OpenNMS.

the class AlarmStatusProviderTest method createNormalAlarmSummaryList.

private List<AlarmSummary> createNormalAlarmSummaryList() {
    List<AlarmSummary> alarms = new ArrayList<>();
    // simulate 1 major alarm
    alarms.add(new AlarmSummary(1, "node1", new Date(), OnmsSeverity.MAJOR, 1L));
    // simulate 5 indeterminate alarms
    alarms.add(new AlarmSummary(3, "node3", new Date(), OnmsSeverity.INDETERMINATE, 5L));
    return alarms;
}
Also used : AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary) ArrayList(java.util.ArrayList) Date(java.util.Date)

Aggregations

AlarmSummary (org.opennms.netmgt.model.alarm.AlarmSummary)11 ArrayList (java.util.ArrayList)5 Status (org.opennms.features.topology.api.topo.Status)5 VertexRef (org.opennms.features.topology.api.topo.VertexRef)5 Collection (java.util.Collection)4 List (java.util.List)4 Map (java.util.Map)4 Objects (java.util.Objects)4 Function (java.util.function.Function)4 Collectors (java.util.stream.Collectors)4 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)4 Criteria (org.opennms.features.topology.api.topo.Criteria)4 StatusProvider (org.opennms.features.topology.api.topo.StatusProvider)4 VertexProvider (org.opennms.features.topology.api.topo.VertexProvider)4 Maps (com.google.common.collect.Maps)3 Set (java.util.Set)3 DefaultStatus (org.opennms.features.topology.api.topo.DefaultStatus)3 AlarmSummaryWrapper (org.opennms.features.topology.plugins.topo.graphml.internal.AlarmSummaryWrapper)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2