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());
}
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;
}
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;
}
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;
}
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;
}
Aggregations