/** {@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 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(); }
/** {@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); }
/** * 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); } }