use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class JmsNorthBounderTest method testAlarmMappingNoParams.
@Test
public void testAlarmMappingNoParams() throws Exception {
String xml = generateMappingConfigXml();
Resource resource = new ByteArrayResource(xml.getBytes());
JmsNorthbounderConfigDao dao = new JmsNorthbounderConfigDao();
dao.setConfigResource(resource);
dao.afterPropertiesSet();
JmsNorthbounderConfig config = dao.getConfig();
List<JmsDestination> destinations = config.getDestinations();
List<JmsNorthbounder> nbis = new LinkedList<>();
for (JmsDestination jmsDestination : destinations) {
JmsNorthbounder nbi = new JmsNorthbounder(config, m_jmsNorthbounderConnectionFactory, jmsDestination);
nbi.afterPropertiesSet();
nbis.add(nbi);
}
List<NorthboundAlarm> alarms = new LinkedList<>();
OnmsNode node = new OnmsNode(null, NODE_LABEL);
node.setForeignSource("TestGroup");
node.setForeignId("2");
node.setId(m_nodeDao.getNextNodeId());
OnmsIpInterface ip = new OnmsIpInterface("127.0.0.1", node);
InetAddress ia = null;
try {
ia = InetAddress.getByName("127.0.0.1");
} catch (UnknownHostException e) {
}
m_nodeDao.save(node);
m_nodeDao.flush();
// TX via NBIs
for (JmsNorthbounder nbi : nbis) {
OnmsEvent event = new OnmsEvent();
event.setId(5);
event.setEventUei("uei.uei.org/uei");
event.setEventTime(new Date());
event.setEventHost("eventhost");
event.setEventSource("eventsource");
event.setIpAddr(ia);
event.setDistPoller(null);
event.setEventSnmpHost("eventsnmphost");
event.setServiceType(null);
event.setEventSnmp("eventsnmp");
event.setEventCreateTime(new Date());
event.setEventDescr("eventdescr");
event.setEventLogGroup("eventloggroup");
event.setEventLogMsg("eventlogmsg");
event.setEventSeverity(4);
event.setEventPathOutage(null);
event.setEventCorrelation(null);
event.setEventSuppressedCount(0);
event.setEventOperInstruct("operinstruct");
event.setEventAutoAction(null);
event.setEventOperAction(null);
event.setEventOperActionMenuText(null);
event.setEventNotification(null);
event.setEventTTicket("tticketid");
event.setEventTTicketState(1);
event.setEventForward(null);
event.setEventMouseOverText(null);
event.setEventLog(null);
event.setEventDisplay(null);
event.setEventAckUser(null);
event.setEventAckTime(null);
event.setAlarm(null);
event.setNode(node);
event.setNotifications(null);
event.setAssociatedServiceRegainedOutages(null);
event.setAssociatedServiceLostOutages(null);
OnmsAlarm alarm = new OnmsAlarm(9, event.getEventUei(), null, 1, 4, new Date(), event);
alarm.setNode(node);
alarm.setDescription(event.getEventDescr());
alarm.setApplicationDN("applicationDN");
alarm.setLogMsg(event.getEventLogMsg());
alarm.setManagedObjectInstance("managedObjectInstance");
alarm.setManagedObjectType("managedObjectType");
alarm.setOssPrimaryKey("ossPrimaryKey");
alarm.setQosAlarmState("qosAlarmState");
alarm.setTTicketId("tticketId");
alarm.setReductionKey("reductionKey");
alarm.setClearKey("clearKey");
alarm.setOperInstruct("operInstruct");
alarm.setAlarmType(OnmsAlarm.PROBLEM_TYPE);
alarm.setFirstEventTime(new Date(0));
alarm.setIpAddr(ia);
alarm.setX733AlarmType(NorthboundAlarm.x733AlarmType.get(1).name());
alarm.setX733ProbableCause(NorthboundAlarm.x733ProbableCause.get(1).getId());
NorthboundAlarm a = new NorthboundAlarm(alarm);
alarms.add(a);
nbi.forwardAlarms(alarms);
}
Thread.sleep(100);
// Let's become a consumer and receive the message
Message m = m_template.receive("MappingTestQueue");
String escapedResponse = "ackUser: appDn: applicationDN logMsg: eventlogmsg objectInstance: managedObjectInstance objectType: managedObjectType ossKey: ossPrimaryKey\n" + " ossState: qosAlarmState ticketId: tticketId alarmUei: uei.uei.org/uei alarmKey: reductionKey clearKey: clearKey description: eventdescr operInstruct: operInstruct ackTime: \n" + " alarmType: PROBLEM count: 1 alarmId: 9 ipAddr: 127.0.0.1 lastOccurrence: nodeId: 1\n" + " nodeLabel: schlazor distPoller: 00000000-0000-0000-0000-000000000000 ifService: severity: WARNING ticketState: x733AlarmType: other\n" + " x733ProbableCause: other firstOccurrence: " + StringUtils.iso8601LocalOffsetString(new Date(0)) + " lastOccurrence eventParmsXml: <eventParms/>";
String response = ((TextMessage) m).getText();
Assert.assertEquals("Contents of message\n'" + response + "'\n not equals\n'" + escapedResponse + "'.", response, escapedResponse);
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class JmsNorthBounderTest method testAlarmMappings.
@Test
public void testAlarmMappings() throws Exception {
String xml = generateMappingConfigXml();
Resource resource = new ByteArrayResource(xml.getBytes());
JmsNorthbounderConfigDao dao = new JmsNorthbounderConfigDao();
dao.setConfigResource(resource);
dao.afterPropertiesSet();
JmsNorthbounderConfig config = dao.getConfig();
List<JmsDestination> destinations = config.getDestinations();
List<JmsNorthbounder> nbis = new LinkedList<>();
for (JmsDestination jmsDestination : destinations) {
JmsNorthbounder nbi = new JmsNorthbounder(config, m_jmsNorthbounderConnectionFactory, jmsDestination);
nbi.afterPropertiesSet();
nbis.add(nbi);
}
List<NorthboundAlarm> alarms = new LinkedList<>();
OnmsNode node = new OnmsNode(null, NODE_LABEL);
node.setForeignSource("TestGroup");
node.setForeignId("2");
node.setId(m_nodeDao.getNextNodeId());
OnmsIpInterface ip = new OnmsIpInterface("127.0.0.1", node);
InetAddress ia = null;
try {
ia = InetAddress.getByName("127.0.0.1");
} catch (UnknownHostException e) {
}
m_nodeDao.save(node);
m_nodeDao.flush();
Date date1 = new Date(0);
Date date2 = new Date();
// TX via NBIs
for (JmsNorthbounder nbi : nbis) {
OnmsEvent event = new OnmsEvent();
event.setId(5);
event.setEventUei("uei.uei.org/uei");
event.setEventTime(new Date());
event.setEventHost("eventhost");
event.setEventSource("eventsource");
event.setIpAddr(ia);
event.setDistPoller(null);
event.setEventSnmpHost("eventsnmphost");
event.setServiceType(null);
event.setEventSnmp("eventsnmp");
event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "syslogmessage", "Dec 22 2015 20:12:57.1 UTC : %UC_CTI-3-CtiProviderOpenFailure: %[CTIconnectionId%61232238][ Login User Id%61pguser][Reason code.%61-1932787616][UNKNOWN_PARAMNAME:IPAddress%61172.17.12.73][UNKNOWN_PARAMNAME:IPv6Address%61][App ID%61Cisco CTIManager][Cluster ID%61SplkCluster][Node ID%61splkcucm6p]: CTI application failed to open provider%59 application startup failed", "string"), new OnmsEventParameter(event, "severity", "Error", "string"), new OnmsEventParameter(event, "timestamp", "Dec 22 14:13:21", "string"), new OnmsEventParameter(event, "process", "229250", "string"), new OnmsEventParameter(event, "service", "local7", "string")));
event.setEventCreateTime(date2);
event.setEventDescr("eventdescr");
event.setEventLogGroup("eventloggroup");
event.setEventLogMsg("eventlogmsg");
event.setEventSeverity(4);
event.setEventPathOutage(null);
event.setEventCorrelation(null);
event.setEventSuppressedCount(0);
event.setEventOperInstruct("operinstruct");
event.setEventAutoAction(null);
event.setEventOperAction(null);
event.setEventOperActionMenuText(null);
event.setEventNotification(null);
event.setEventTTicket("tticketid");
event.setEventTTicketState(1);
event.setEventForward(null);
event.setEventMouseOverText(null);
event.setEventLog(null);
event.setEventDisplay(null);
event.setEventAckUser(null);
event.setEventAckTime(null);
event.setAlarm(null);
event.setNode(node);
event.setNotifications(null);
event.setAssociatedServiceRegainedOutages(null);
event.setAssociatedServiceLostOutages(null);
OnmsAlarm alarm = new OnmsAlarm(9, event.getEventUei(), null, 1, 4, new Date(), event);
alarm.setNode(node);
alarm.setDescription(event.getEventDescr());
alarm.setApplicationDN("applicationDN");
alarm.setLogMsg(event.getEventLogMsg());
alarm.setManagedObjectInstance("managedObjectInstance");
alarm.setManagedObjectType("managedObjectType");
alarm.setOssPrimaryKey("ossPrimaryKey");
alarm.setQosAlarmState("qosAlarmState");
alarm.setTTicketId("tticketId");
alarm.setReductionKey("reductionKey");
alarm.setClearKey("clearKey");
alarm.setOperInstruct("operInstruct");
alarm.setAlarmType(OnmsAlarm.PROBLEM_TYPE);
alarm.setFirstEventTime(date1);
alarm.setIpAddr(ia);
alarm.setLastEvent(event);
alarm.setX733AlarmType(NorthboundAlarm.x733AlarmType.get(1).name());
alarm.setX733ProbableCause(NorthboundAlarm.x733ProbableCause.get(1).getId());
NorthboundAlarm a = new NorthboundAlarm(alarm);
alarm.setCounter(2);
NorthboundAlarm b = new NorthboundAlarm(alarm);
alarms.add(a);
alarms.add(b);
nbi.forwardAlarms(alarms);
}
Thread.sleep(100);
// Let's become a consumer and receive the message
Message m = m_template.receive("MappingTestQueue");
String escapedResponse = "ackUser: appDn: applicationDN logMsg: eventlogmsg objectInstance: managedObjectInstance objectType: managedObjectType ossKey: ossPrimaryKey\n" + " ossState: qosAlarmState ticketId: tticketId alarmUei: uei.uei.org/uei alarmKey: reductionKey clearKey: clearKey description: eventdescr operInstruct: operInstruct ackTime: \n" + " alarmType: PROBLEM count: 1 alarmId: 9 ipAddr: 127.0.0.1 lastOccurrence: " + StringUtils.iso8601LocalOffsetString(date2) + " nodeId: 1\n" + " nodeLabel: schlazor distPoller: 00000000-0000-0000-0000-000000000000 ifService: severity: WARNING ticketState: x733AlarmType: other\n" + " x733ProbableCause: other firstOccurrence: " + StringUtils.iso8601LocalOffsetString(date1) + " lastOccurrence " + StringUtils.iso8601LocalOffsetString(date2) + " eventParmsXml: <eventParms>\n" + " <parm name=\"syslogmessage\" value=\"Dec 22 2015 20:12:57.1 UTC : %UC_CTI-3-CtiProviderOpenFailure: %[CTIconnectionId%61232238][ Login User Id%61pguser][Reason code.%61-1932787616][UNKNOWN_PARAMNAME:IPAddress%61172.17.12.73][UNKNOWN_PARAMNAME:IPv6Address%61][App ID%61Cisco CTIManager][Cluster ID%61SplkCluster][Node ID%61splkcucm6p]: CTI application failed to open provider%59 application startup failed\" type=\"string\"/>\n" + " <parm name=\"severity\" value=\"Error\" type=\"string\"/>\n" + " <parm name=\"timestamp\" value=\"Dec 22 14:13:21\" type=\"string\"/>\n" + " <parm name=\"process\" value=\"229250\" type=\"string\"/>\n" + " <parm name=\"service\" value=\"local7\" type=\"string\"/>\n" + "</eventParms>";
String response = ((TextMessage) m).getText();
Assert.assertEquals("Contents of message\n'" + response + "'\n not equals\n'" + escapedResponse + "'.", response, escapedResponse);
// ensure only 1 message received since same reduction key
m_template.setReceiveTimeout(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT);
m = m_template.receive("MappingTestQueue");
Assert.assertNull(m);
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class SyslogFilterTest method testFilterParsing.
/**
* Test filter parsing.
*
* @throws Exception the exception
*/
@Test
public void testFilterParsing() throws Exception {
OnmsEvent event = new OnmsEvent();
event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "user", "agalue", "string"), new OnmsEventParameter(event, "passwd", "0nmsRules", "string")));
OnmsAlarm onmsAlarm = new OnmsAlarm();
onmsAlarm.setLastEvent(event);
onmsAlarm.setUei("uei.opennms.org/junit/test");
NorthboundAlarm alarm = new NorthboundAlarm(onmsAlarm);
SyslogFilter filter = new SyslogFilter("test", "uei matches '^uei\\.opennms\\.org.*' and parameters['user'] == 'agalue'", "localhost");
Assert.assertTrue(filter.passFilter(alarm));
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class SurveillanceViewAlarmTable method refreshDetails.
/**
* {@inheritDoc}
*/
@Override
public void refreshDetails(final Set<OnmsCategory> rowCategories, final Set<OnmsCategory> colCategories) {
if (m_future != null && !m_future.isDone()) {
return;
}
m_future = getSurveillanceViewService().getExecutorService().submit(new Callable<List<Alarm>>() {
@Override
public List<Alarm> call() throws Exception {
/**
* retrieve the matching alarms
*/
List<OnmsAlarm> onmsAlarms = getSurveillanceViewService().getAlarmsForCategories(rowCategories, colCategories);
List<Alarm> alarms = new ArrayList<>();
Map<Integer, OnmsNode> nodeMap = new HashMap<>();
for (OnmsAlarm onmsAlarm : onmsAlarms) {
if (!nodeMap.containsKey(onmsAlarm.getNodeId())) {
nodeMap.put(onmsAlarm.getNodeId(), getSurveillanceViewService().getNodeForId(onmsAlarm.getNodeId()));
}
alarms.add(new Alarm(onmsAlarm.getId(), onmsAlarm.getUei(), onmsAlarm.getSeverityId(), onmsAlarm.getSeverity().getLabel(), nodeMap.get(onmsAlarm.getNodeId()).getLabel(), onmsAlarm.getNodeId(), onmsAlarm.getLogMsg(), onmsAlarm.getCounter(), onmsAlarm.getFirstEventTime(), onmsAlarm.getLastEventTime()));
}
return alarms;
}
});
m_future.addListener(new Runnable() {
@Override
public void run() {
try {
final List<Alarm> alarms = m_future.get();
getUI().access(new Runnable() {
@Override
public void run() {
/**
* empty the container
*/
m_beanItemContainer.removeAllItems();
/**
* add items to container
*/
if (alarms != null && !alarms.isEmpty()) {
for (Alarm alarm : alarms) {
m_beanItemContainer.addItem(alarm);
}
}
/**
* sort the alarms
*/
sort(new Object[] { "severityId", "lastEventTime" }, new boolean[] { false, false });
/**
* refresh the table
*/
refreshRowCache();
}
});
} catch (InterruptedException e) {
LOG.error("Interrupted", e);
} catch (ExecutionException e) {
LOG.error("Exception in task", e.getCause());
}
}
}, MoreExecutors.directExecutor());
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class LinkdEdgeStatusProviderTest method createOspfDownAlarm.
private List<OnmsAlarm> createOspfDownAlarm() {
List<OnmsAlarm> alarms = new ArrayList<>();
OnmsAlarm alarm1 = new OnmsAlarm();
alarm1.setNode(m_node4);
alarm1.setIfIndex(10101);
alarm1.setUei(EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI);
alarms.add(alarm1);
return alarms;
}
Aggregations