use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class LinkdEdgeStatusProviderTest method createIsIsDownAlarm.
private List<OnmsAlarm> createIsIsDownAlarm() {
List<OnmsAlarm> alarms = new ArrayList<>();
OnmsAlarm alarm1 = new OnmsAlarm();
alarm1.setNode(m_node5);
alarm1.setIfIndex(578);
alarm1.setUei(EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI);
alarms.add(alarm1);
return alarms;
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class LinkdEdgeStatusProviderTest method createChennaiDownAlarm.
private List<OnmsAlarm> createChennaiDownAlarm() {
List<OnmsAlarm> alarms = new ArrayList<>();
OnmsAlarm alarm1 = new OnmsAlarm();
alarm1.setNode(m_nodeChennai);
alarm1.setIfIndex(13);
alarm1.setUei(EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI);
alarms.add(alarm1);
return alarms;
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmDetailsDashlet method getAlarms.
/**
* Returns the alarms defined by this dashlet.
*
* @return the list of alarms
*/
private List<OnmsAlarm> getAlarms() {
final CriteriaBuilder alarmCb = new CriteriaBuilder(OnmsAlarm.class);
alarmCb.alias("node", "node");
alarmCb.alias("node.categories", "category");
alarmCb.alias("lastEvent", "event");
String criteria = getDashletSpec().getParameters().get("criteria");
m_criteriaBuilderHelper.parseConfiguration(alarmCb, criteria);
alarmCb.fetch("firstEvent", Fetch.FetchType.EAGER);
alarmCb.fetch("lastEvent", Fetch.FetchType.EAGER);
/**
* due to restrictions in the criteria api it's quite hard
* to use distinct and orderBy together, so I apply a workaround
* to avoid alarmCb.distinct();
*/
List<OnmsAlarm> onmsAlarmList = m_alarmDao.findMatching(alarmCb.toCriteria());
Map<Integer, OnmsAlarm> onmsAlarmMap = new LinkedHashMap<>();
for (OnmsAlarm onmsAlarm : onmsAlarmList) {
if (!onmsAlarmMap.containsKey(onmsAlarm.getId())) {
onmsAlarmMap.put(onmsAlarm.getId(), onmsAlarm);
}
}
return Lists.newArrayList(onmsAlarmMap.values());
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmsDashlet method addComponents.
/**
* Adds the alarms components to a {@link com.vaadin.ui.AbstractOrderedLayout}
*
* @param component the component to add alarms to
* @param alarms the alarms list
*/
private void addComponents(AbstractOrderedLayout component, List<OnmsAlarm> alarms) {
if (alarms.size() == 0) {
Label label = new Label("No alarms found!");
label.addStyleName("alerts-noalarms-font");
component.addComponent(label);
} else {
for (OnmsAlarm onmsAlarm : alarms) {
OnmsNode onmsNode = null;
if (onmsAlarm.getNodeId() != null) {
CriteriaBuilder nodeCb = new CriteriaBuilder(OnmsNode.class);
nodeCb.eq("id", onmsAlarm.getNodeId());
List<OnmsNode> nodes = m_nodeDao.findMatching(nodeCb.toCriteria());
if (nodes.size() == 1) {
onmsNode = nodes.get(0);
}
}
component.addComponent(createAlarmComponent(onmsAlarm, onmsNode));
OnmsSeverity boostSeverity = OnmsSeverity.valueOf(getDashletSpec().getParameters().get("boostSeverity"));
if (onmsAlarm.getSeverity().isGreaterThanOrEqual(boostSeverity)) {
boosted = true;
}
}
}
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmStatsRestServiceIT method createAlarm.
private OnmsAlarm createAlarm(final OnmsSeverity severity, final String ackUser) {
final OnmsEvent event = createEvent();
final OnmsAlarm alarm = new OnmsAlarm();
alarm.setDistPoller(m_distPollerDao.whoami());
alarm.setUei(event.getEventUei());
alarm.setAlarmType(OnmsAlarm.PROBLEM_TYPE);
alarm.setNode(m_databasePopulator.getNode1());
alarm.setDescription("This is a test alarm");
alarm.setLogMsg("this is a test alarm log message");
alarm.setCounter(1);
alarm.setIpAddr(InetAddressUtils.UNPINGABLE_ADDRESS);
alarm.setSeverity(severity);
alarm.setFirstEventTime(event.getEventTime());
alarm.setLastEvent(event);
alarm.setServiceType(event.getServiceType());
if (ackUser != null) {
alarm.setAlarmAckTime(new Date(1282329200000L));
alarm.setAlarmAckUser(ackUser);
}
m_alarmDao.save(alarm);
m_alarmDao.flush();
LOG.debug("CreateAlarm: {}", alarm);
return alarm;
}
Aggregations