/** {@inheritDoc} */ @Override public Integer resolveOutagePendingRegainEventId( int nodeId, String ipAddr, String svcName, Date regainedTime) { LOG.info("resolving outage for {}:{}:{} @ {}", nodeId, ipAddr, svcName, regainedTime); final OnmsMonitoredService service = m_monitoredServiceDao.get(nodeId, InetAddressUtils.addr(ipAddr), svcName); if (service == null) { LOG.warn( "Failed to resolve the pending outage for {}:{}:{} @ {}. The service could not be found.", nodeId, ipAddr, svcName, regainedTime); return null; } final OnmsOutage outage = m_outageDao.currentOutageForService(service); if (outage == null) { return null; } // Update the outage outage.setIfRegainedService(new Timestamp(regainedTime.getTime())); m_outageDao.saveOrUpdate(outage); return outage.getId(); }
/** {@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); }
/** {@inheritDoc} */ @Override public Integer openOutagePendingLostEventId( int nodeId, String ipAddr, String svcName, Date lostTime) { LOG.info("opening outage for {}:{}:{} @ {}", nodeId, ipAddr, svcName, lostTime); final OnmsMonitoredService service = m_monitoredServiceDao.get(nodeId, InetAddressUtils.addr(ipAddr), svcName); final OnmsOutage outage = new OnmsOutage(lostTime, service); m_outageDao.saveOrUpdate(outage); return outage.getId(); }
/** * closeOutagesForNode * * @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); } }
@Override public void closeOutagesForUnmanagedServices() { Date closeDate = new java.util.Date(); Criteria criteria = new Criteria(OnmsOutage.class); criteria.setAliases( Arrays.asList( new Alias[] {new Alias("monitoredService", "monitoredService", JoinType.LEFT_JOIN)})); criteria.addRestriction( new AnyRestriction( new EqRestriction("monitoredService.status", "D"), new EqRestriction("monitoredService.status", "F"), new EqRestriction("monitoredService.status", "U"))); criteria.addRestriction(new NullRestriction("ifRegainedService")); List<OnmsOutage> outages = m_outageDao.findMatching(criteria); for (OnmsOutage outage : outages) { outage.setIfRegainedService(closeDate); m_outageDao.update(outage); } criteria = new Criteria(OnmsOutage.class); criteria.setAliases( Arrays.asList( new Alias[] { new Alias("monitoredService.ipInterface", "ipInterface", JoinType.LEFT_JOIN) })); criteria.addRestriction( new AnyRestriction( new EqRestriction("ipInterface.isManaged", "F"), new EqRestriction("ipInterface.isManaged", "U"))); criteria.addRestriction(new NullRestriction("ifRegainedService")); outages = m_outageDao.findMatching(criteria); for (OnmsOutage outage : outages) { outage.setIfRegainedService(closeDate); m_outageDao.update(outage); } }
public void resetDatabase() { LOG.debug("==== DatabasePopulator Reset ===="); for (final DataLinkInterface iface : m_dataLinkInterfaceDao.findAll()) { m_dataLinkInterfaceDao.delete(iface); } for (final OnmsOutage outage : m_outageDao.findAll()) { m_outageDao.delete(outage); } for (final OnmsUserNotification not : m_userNotificationDao.findAll()) { m_userNotificationDao.delete(not); } for (final OnmsNotification not : m_notificationDao.findAll()) { m_notificationDao.delete(not); } for (final OnmsAlarm alarm : m_alarmDao.findAll()) { m_alarmDao.delete(alarm); } for (final OnmsEvent event : m_eventDao.findAll()) { m_eventDao.delete(event); } for (final OnmsSnmpInterface iface : m_snmpInterfaceDao.findAll()) { m_snmpInterfaceDao.delete(iface); } for (final OnmsIpInterface iface : m_ipInterfaceDao.findAll()) { m_ipInterfaceDao.delete(iface); } for (final OnmsNode node : m_nodeDao.findAll()) { m_nodeDao.delete(node); } for (final OnmsServiceType service : m_serviceTypeDao.findAll()) { m_serviceTypeDao.delete(service); } LOG.debug("= DatabasePopulatorExtension Reset Starting ="); for (Extension eachExtension : extensions) { DaoSupport daoSupport = eachExtension.getDaoSupport(); OnmsDao dao = daoSupport != null && daoSupport.getDaoClass() != null ? lookupDao(daoSupport.getDaoClass()) : null; eachExtension.onShutdown(this, dao); if (dao != null) { dao.flush(); } } LOG.debug("= DatabasePopulatorExtension Reset Finished ="); m_dataLinkInterfaceDao.flush(); m_outageDao.flush(); m_userNotificationDao.flush(); m_notificationDao.flush(); m_alarmDao.flush(); m_eventDao.flush(); m_snmpInterfaceDao.flush(); m_ipInterfaceDao.flush(); m_nodeDao.flush(); m_serviceTypeDao.flush(); LOG.debug("==== DatabasePopulator Reset Finished ===="); }