use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmRepositoryHibernate method removeStickyMemo.
/**
* {@inheritDoc}
*/
@Override
@Transactional
public void removeStickyMemo(Integer alarmId) {
OnmsAlarm onmsAlarm = m_alarmDao.get(alarmId);
if (onmsAlarm != null && onmsAlarm.getStickyMemo() != null) {
m_memoDao.delete(onmsAlarm.getStickyMemo());
onmsAlarm.setStickyMemo(null);
}
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmRepositoryHibernate method unacknowledgeMatchingAlarms.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void unacknowledgeMatchingAlarms(OnmsCriteria criteria, String user) {
List<OnmsAlarm> alarms = m_alarmDao.findMatching(criteria);
for (OnmsAlarm alarm : alarms) {
OnmsAcknowledgment ack = new OnmsAcknowledgment(alarm, user);
ack.setAckAction(AckAction.UNACKNOWLEDGE);
m_ackDao.processAck(ack);
}
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmRepositoryHibernate method escalateAlarms.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void escalateAlarms(int[] alarmIds, String user, Date timestamp) {
OnmsCriteria criteria = new OnmsCriteria(OnmsAlarm.class);
criteria.add(Restrictions.in("id", Arrays.asList(ArrayUtils.toObject(alarmIds))));
List<OnmsAlarm> alarms = m_alarmDao.findMatching(criteria);
Iterator<OnmsAlarm> alarmsIt = alarms.iterator();
while (alarmsIt.hasNext()) {
OnmsAlarm alarm = alarmsIt.next();
OnmsAcknowledgment ack = new OnmsAcknowledgment(alarm, user);
ack.setAckTime(timestamp);
ack.setAckAction(AckAction.ESCALATE);
m_ackDao.processAck(ack);
}
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class ApplicationDaoHibernate method getApplicationStatus.
@Override
public List<ApplicationStatus> getApplicationStatus(List<OnmsApplication> applications) {
// Applications do not have a alarm mapping, so we grab all nodeDown, interfaceDown and serviceLost alarms
// for all monitored services of each application to calculate the maximum severity (-> status)
final List<ApplicationStatus> statusList = new ArrayList<>();
for (OnmsApplication application : applications) {
final Set<String> reductionKeys = new HashSet<>();
for (OnmsMonitoredService eachService : application.getMonitoredServices()) {
reductionKeys.addAll(ReductionKeyHelper.getReductionKeys(eachService));
}
if (!reductionKeys.isEmpty()) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class);
builder.in("reductionKey", reductionKeys);
// findMatching would exepct OnmsApplications, but we need OnmsAlarms, so hack it
HibernateCallback<List<OnmsAlarm>> callback = buildHibernateCallback(builder.toCriteria());
List<OnmsAlarm> alarms = getHibernateTemplate().execute(callback);
// All alarms for the current application have been determined, now get the max severity
final Optional<OnmsAlarm> maxSeverity = alarms.stream().reduce((leftAlarm, rightAlarm) -> {
if (leftAlarm.getSeverity().isGreaterThan(rightAlarm.getSeverity())) {
return leftAlarm;
}
return rightAlarm;
});
if (maxSeverity.isPresent()) {
statusList.add(new ApplicationStatus(application, maxSeverity.get().getSeverity()));
} else {
// ensure that each application has a status
statusList.add(new ApplicationStatus(application, OnmsSeverity.NORMAL));
}
} else {
// ensure that each application has a status
statusList.add(new ApplicationStatus(application, OnmsSeverity.NORMAL));
}
}
return statusList;
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class NCSNorthbounderIT method alarm.
private NorthboundAlarm alarm(int alarmId) {
OnmsEvent event = new OnmsEvent();
event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "componentType", "Service", "string"), new OnmsEventParameter(event, "componentName", "NAM" + alarmId, "string"), new OnmsEventParameter(event, "componentForeignSource", "FS", "string"), new OnmsEventParameter(event, "componentForeignId", "" + alarmId, "string"), new OnmsEventParameter(event, "cause", "17", "string")));
OnmsAlarm alarm = new OnmsAlarm();
alarm.setId(alarmId);
alarm.setUei("uei.opennms.org/test/httpNorthBounder");
alarm.setLastEvent(event);
alarm.setAlarmType((alarmId + 1) % 2 + 1);
return new NorthboundAlarm(alarm);
}
Aggregations