/** * Builds an XML representation of parameter mappings. * @param alarm the alarm * @param mapping the mapping */ private void buildParmMappingXml(final NorthboundAlarm alarm, final Map<String, Object> mapping) { List<OnmsEventParameter> parms = alarm.getEventParametersCollection(); EventParms eventParms = new EventParms(parms); try { JAXBElement<EventParms> rootElement = new JAXBElement<EventParms>(new QName("eventParms"), EventParms.class, eventParms); StringWriter sw = new StringWriter(); Marshaller marshaller = ONMS_EVENT_PARM_CONTEXT.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.marshal(rootElement, sw); LOG.debug("Adding eventParmsXML mapping with contents {}.", sw); mapping.put("eventParmsXml", sw); } catch (JAXBException e) { LOG.error("Error marshalling event params to XML for alarm ID: {}", alarm.getId(), e); } }
/** * Builds an XML representation of parameter mappings. * @param alarm the alarm * @param mapping the mapping */ private void buildParmMappingXml(final NorthboundAlarm alarm, final Map<String, Object> mapping) { List<OnmsEventParameter> parms = alarm.getEventParametersCollection(); EventParms eventParms = new EventParms(parms); try { JAXBElement<EventParms> rootElement = new JAXBElement<EventParms>(new QName("eventParms"), EventParms.class, eventParms); StringWriter sw = new StringWriter(); Marshaller marshaller = ONMS_EVENT_PARM_CONTEXT.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.marshal(rootElement, sw); LOG.debug("Adding eventParmsXML mapping with contents {}.", sw); mapping.put("eventParmsXml", sw); } catch (JAXBException e) { LOG.error("Error marshalling event params to XML for alarm ID: {}", alarm.getId(), e); } }
/** * Each implementation of the AbstractNorthbounder has a nice queue (Nagle's algorithmic) and the worker thread that processes the queue * calls this method to send alarms to the northern NMS. * * @param alarms the alarms * @throws NorthbounderException the northbounder exception */ @Override public void forwardAlarms(List<NorthboundAlarm> alarms) throws NorthbounderException { if (alarms == null) { String errorMsg = "No alarms in alarms list for drools forwarding."; NorthbounderException e = new NorthbounderException(errorMsg); LOG.error(errorMsg, e); throw e; } LOG.info("Forwarding {} alarms to engine {}", alarms.size(), m_engine.getName()); alarms.forEach(a -> { LOG.debug("Begin correlation for alarm {} uei: {}", a.getId(), a.getUei()); m_kieSession.insert(a); LOG.debug("End correlation for alarm {} uei: {}", a.getId(), a.getUei()); }); }
continue; LOG.debug("Creating formatted log message for alarm: {}.", alarm.getId()); String syslogMessage; int level; try { LOG.debug("Making substitutions for tokens in message format for alarm: {}.", alarm.getId()); String msgFormat = m_destination.getCustomMessageFormat(alarm); if (msgFormat == null) { syslogMessage = PropertiesUtils.substitute(msgFormat, createMapping(alarm, dateFormat)); LOG.debug("Determining LOG_LEVEL for alarm: {}", alarm.getId()); level = SyslogUtils.determineLogLevel(alarm.getSeverity()); LOG.debug("Forwarding alarm: {} via syslog to destination: {}", alarm.getId(), m_destination.getName()); instance.log(level, syslogMessage);
/** * Convert alarm to text. * * @param alarm the alarm * @return the string */ private String convertAlarmToText(NorthboundAlarm alarm) { String alarmXml = null; Map<String, Object> mapping = createMapping(alarm, null); LOG.debug("Making substitutions for tokens in message format for alarm: {}.", alarm.getId()); if (m_jmsDestination.getMessageFormat() != null) { alarmXml = PropertiesUtils.substitute(m_jmsDestination.getMessageFormat(), mapping); } else { alarmXml = PropertiesUtils.substitute(m_config.getMessageFormat(), mapping); } return alarmXml; }
mapping.put("alarmId", alarm.getId().toString()); mapping.put("ipAddr", nullSafeToString(alarm.getIpAddr(), defaultMapping)); if (dateFormat != null) {
mapping.put("alarmId", alarm.getId().toString()); mapping.put("ipAddr", nullSafeToString(alarm.getIpAddr(), defaultMapping)); if (dateFormat != null) {