map.put("Number of Events", getResource(Integer.toString(m_eventDao.countAll())));
private void deleteEvents(final String foreignSource, final String foreignId) { final Map<String, String> eventParameters = new HashMap<>(); eventParameters.put("componentForeignSource", foreignSource); eventParameters.put("componentForeignId", foreignId); for(final OnmsEvent event : m_eventDao.getEventsForEventParameters(eventParameters)) { m_eventDao.delete(event); } } }
/** {@inheritDoc} */ @Override public void updateOpenOutageWithEventId(int outageId, int lostEventId) { LOG.info("updating open outage {} with event id {}", outageId, lostEventId); final OnmsEvent event = m_eventDao.get(lostEventId); final OnmsOutage outage = m_outageDao.get(outageId); if (outage == null) { LOG.warn("Failed to update outage {} with event id {}. The outage no longer exists.", outageId, lostEventId); return; } // Update the outage outage.setServiceLostEvent(event); m_outageDao.saveOrUpdate(outage); }
private OnmsAlarm addOrReduceEventAsAlarm(Event event) throws IllegalStateException { final OnmsEvent persistedEvent = m_eventDao.get(event.getDbid()); if (persistedEvent == null) { throw new IllegalStateException("Event with id " + event.getDbid() + " was deleted before we could retrieve it and create an alarm."); m_eventDao.saveOrUpdate(persistedEvent); m_eventDao.update(persistedEvent); m_eventDao.deletePreviousEventsForAlarm(alarm.getId(), persistedEvent);
/** * {@inheritDoc} * * The method that inserts the event into the database */ private void process(final Header eventHeader, final Event event) throws EventProcessorException { LOG.debug("HibernateEventWriter: processing {}, nodeid: {}, ipaddr: {}, serviceid: {}, time: {}", event.getUei(), event.getNodeid(), event.getInterface(), event.getService(), event.getTime()); try { final OnmsEvent ovent = createOnmsEvent(eventHeader, event); eventDao.save(ovent); // Update the event with the database ID of the event stored in the database event.setDbid(ovent.getId()); } catch (DeadlockLoserDataAccessException e) { throw new EventProcessorException("Encountered deadlock when inserting event: " + event.toString(), e); } catch (Throwable e) { throw new EventProcessorException("Unexpected exception while storing event: " + event.toString(), e); } }
m_eventDao.saveOrUpdate(oe);
private OnmsAlarm addOrReduceEventAsAlarm(Event event) throws IllegalStateException { final OnmsEvent persistedEvent = m_eventDao.get(event.getDbid()); if (persistedEvent == null) { throw new IllegalStateException("Event with id " + event.getDbid() + " was deleted before we could retrieve it and create an alarm."); m_eventDao.saveOrUpdate(persistedEvent); m_eventDao.update(persistedEvent); m_eventDao.deletePreviousEventsForAlarm(alarm.getId(), persistedEvent);
/** * {@inheritDoc} * * The method that inserts the event into the database */ private void process(final Header eventHeader, final Event event) throws EventProcessorException { LOG.debug("HibernateEventWriter: processing {}, nodeid: {}, ipaddr: {}, serviceid: {}, time: {}", event.getUei(), event.getNodeid(), event.getInterface(), event.getService(), event.getTime()); try { final OnmsEvent ovent = createOnmsEvent(eventHeader, event); eventDao.save(ovent); // Update the event with the database ID of the event stored in the database event.setDbid(ovent.getId()); } catch (DeadlockLoserDataAccessException e) { throw new EventProcessorException("Encountered deadlock when inserting event: " + event.toString(), e); } catch (Throwable e) { throw new EventProcessorException("Unexpected exception while storing event: " + event.toString(), e); } }
m_eventDao.saveOrUpdate(oe);
private void updateSubObjects(final OnmsAlarm alarm) { // Assume that the system ID is the ID of an OpenNMS system // instead of a Minion or Remote Poller getDistPollerDao().save((OnmsDistPoller)alarm.getDistPoller()); getEventDao().save(alarm.getLastEvent()); getNodeDao().save(alarm.getNode()); getServiceTypeDao().save(alarm.getServiceType()); }
/** {@inheritDoc} */ @Override public void updateResolvedOutageWithEventId(int outageId, int regainedEventId) { LOG.info("updating resolved outage {} with event id {}", outageId, regainedEventId); final OnmsEvent event = m_eventDao.get(regainedEventId); final OnmsOutage outage = m_outageDao.get(outageId); if (outage == null) { LOG.warn("Failed to update outage {} with event id {}. The outage no longer exists.", outageId, regainedEventId); return; } // Update the outage outage.setServiceRegainedEvent(event); m_outageDao.saveOrUpdate(outage); }
map.put("Number of Events", getResource(Integer.toString(m_eventDao.countAll())));
private void updateSubObjects(final OnmsAlarm alarm) { // Assume that the system ID is the ID of an OpenNMS system // instead of a Minion or Remote Poller getDistPollerDao().save((OnmsDistPoller)alarm.getDistPoller()); getEventDao().save(alarm.getLastEvent()); getNodeDao().save(alarm.getNode()); getServiceTypeDao().save(alarm.getServiceType()); }
/** * <p>closeOutagesForNode</p> * * @param closeDate a {@link java.util.Date} object. * @param eventId a int. * @param nodeId a int. */ @Override public void closeOutagesForNode(Date closeDate, int eventId, int nodeId) { Criteria criteria = new Criteria(OnmsOutage.class); criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN), new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN) })); criteria.addRestriction(new EqRestriction("node.id", nodeId)); criteria.addRestriction(new NullRestriction("ifRegainedService")); List<OnmsOutage> outages = m_outageDao.findMatching(criteria); for (OnmsOutage outage : outages) { outage.setIfRegainedService(closeDate); outage.setServiceRegainedEvent(m_eventDao.get(eventId)); m_outageDao.update(outage); } }
public UsageStatisticsReportDTO generateReport() { final SystemInfoUtils sysInfoUtils = new SystemInfoUtils(); final UsageStatisticsReportDTO usageStatisticsReport = new UsageStatisticsReportDTO(); // Unique system identifier try { usageStatisticsReport.setSystemId(m_stateManager.getOrGenerateSystemId()); } catch (IOException e) { LOG.warn("An error occurred while retrieving the system id. " + "The usage report will be submitted with a null system id.", e); } // Operating System usageStatisticsReport.setOsName(System.getProperty("os.name")); usageStatisticsReport.setOsArch(System.getProperty("os.arch")); usageStatisticsReport.setOsVersion(System.getProperty("os.version")); // OpenNMS version and flavor usageStatisticsReport.setVersion(sysInfoUtils.getVersion()); usageStatisticsReport.setPackageName(sysInfoUtils.getPackageName()); // Object counts usageStatisticsReport.setNodes(m_nodeDao.countAll()); usageStatisticsReport.setIpInterfaces(m_ipInterfaceDao.countAll()); usageStatisticsReport.setSnmpInterfaces(m_snmpInterfaceDao.countAll()); usageStatisticsReport.setMonitoredServices(m_monitoredServiceDao.countAll()); usageStatisticsReport.setEvents(m_eventDao.countAll()); usageStatisticsReport.setAlarms(m_alarmDao.countAll()); // Node statistics usageStatisticsReport.setNodesBySysOid(m_nodeDao.getNumberOfNodesBySysOid()); return usageStatisticsReport; }
/** * <p>closeOutagesForInterface</p> * * @param closeDate a {@link java.util.Date} object. * @param eventId a int. * @param nodeId a int. * @param ipAddr a {@link java.lang.String} object. */ @Override public void closeOutagesForInterface(Date closeDate, int eventId, int nodeId, String ipAddr) { Criteria criteria = new Criteria(OnmsOutage.class); criteria.setAliases(Arrays.asList(new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN), new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN) })); criteria.addRestriction(new EqRestriction("node.id", nodeId)); criteria.addRestriction(new EqRestriction("ipInterface.ipAddress", addr(ipAddr))); criteria.addRestriction(new NullRestriction("ifRegainedService")); List<OnmsOutage> outages = m_outageDao.findMatching(criteria); for (OnmsOutage outage : outages) { outage.setIfRegainedService(closeDate); outage.setServiceRegainedEvent(m_eventDao.get(eventId)); m_outageDao.update(outage); } }
public UsageStatisticsReportDTO generateReport() { final SystemInfoUtils sysInfoUtils = new SystemInfoUtils(); final UsageStatisticsReportDTO usageStatisticsReport = new UsageStatisticsReportDTO(); // Unique system identifier try { usageStatisticsReport.setSystemId(m_stateManager.getOrGenerateSystemId()); } catch (IOException e) { LOG.warn("An error occurred while retrieving the system id. " + "The usage report will be submitted with a null system id.", e); } // Operating System usageStatisticsReport.setOsName(System.getProperty("os.name")); usageStatisticsReport.setOsArch(System.getProperty("os.arch")); usageStatisticsReport.setOsVersion(System.getProperty("os.version")); // OpenNMS version and flavor usageStatisticsReport.setVersion(sysInfoUtils.getVersion()); usageStatisticsReport.setPackageName(sysInfoUtils.getPackageName()); // Object counts usageStatisticsReport.setNodes(m_nodeDao.countAll()); usageStatisticsReport.setIpInterfaces(m_ipInterfaceDao.countAll()); usageStatisticsReport.setSnmpInterfaces(m_snmpInterfaceDao.countAll()); usageStatisticsReport.setMonitoredServices(m_monitoredServiceDao.countAll()); usageStatisticsReport.setEvents(m_eventDao.countAll()); usageStatisticsReport.setAlarms(m_alarmDao.countAll()); // Node statistics usageStatisticsReport.setNodesBySysOid(m_nodeDao.getNumberOfNodesBySysOid()); return usageStatisticsReport; }
outage.setServiceRegainedEvent(m_eventDao.get(eventId)); m_outageDao.update(outage); LOG.info("Calling closeOutagesForService: {}",outage);