Search in sources :

Example 61 with OnmsAlarm

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;
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) ArrayList(java.util.ArrayList)

Example 62 with OnmsAlarm

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;
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) ArrayList(java.util.ArrayList)

Example 63 with OnmsAlarm

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());
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) LinkedHashMap(java.util.LinkedHashMap)

Example 64 with OnmsAlarm

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;
            }
        }
    }
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Label(com.vaadin.ui.Label)

Example 65 with OnmsAlarm

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;
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Date(java.util.Date)

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