/** {@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(); }
/** * This method should be called before scheduling services with outstanding * outages for the first time. * * If an outage is open, but has no lost service event, we will mark it as closed * with the current timestamp. This can happen if the poller daemon is stopped after * creating the outage record, but before the event was received back from the event bus. * * We close the outage immediately, as opposed to marking the service's initial state * as down since we do not know the cause, and determining the cause from the current * state of the database is error prone. * * Closing the outage immediately also prevents the daemon from creating * duplicate outstanding outage records. */ private void closeOutageIfSvcLostEventIsMissing(final OnmsOutage outage) { if (outage == null || outage.getServiceLostEvent() != null || outage.getIfRegainedService() != null) { // Nothing to do return; } LOG.warn("Outage {} was left open without a lost service event. " + "The outage will be closed.", outage); final Date now = new Date(); outage.setIfRegainedService(now); m_outageDao.update(outage); }
/** * <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); } }
outage.setIfRegainedService(closeDate); m_outageDao.update(outage); outage.setIfRegainedService(closeDate); m_outageDao.update(outage);
outage.setIfRegainedService(closeDate); outage.setServiceRegainedEvent(m_eventDao.get(eventId)); m_outageDao.update(outage);
/** * <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); } }
outage.setMonitoredService(icmpService); outage.setIfLostService(oneHourAgo); outage.setIfRegainedService(thirtyMinutesAgo); m_outageDao.save(outage); m_outageDao.flush();