private OnmsMonitoredService getMonitoredServiceEntity(Integer serviceId) throws NoSuchElementException { Objects.requireNonNull(serviceId); final OnmsMonitoredService monitoredService = monitoredServiceDao.get(serviceId); if (monitoredService == null) { throw new NoSuchElementException("OnmsMonitoredService with id " + serviceId); } return monitoredService; }
/** {@inheritDoc} */ @Override public List<OnmsApplication> findByMonitoredService(int id) { OnmsMonitoredService service = m_monitoredServiceDao.get(id); if (service == null) { throw new IllegalArgumentException("monitored service with " + "id of " + id + " could not be found"); } List<OnmsApplication> sortedApplications = new ArrayList<OnmsApplication>(service.getApplications()); Collections.sort(sortedApplications); return sortedApplications; }
private OnmsMonitoredService findService(String ifServiceIdString) { int ifServiceId; try { ifServiceId = WebSecurityUtils.safeParseInt(ifServiceIdString); } catch (NumberFormatException e) { throw new IllegalArgumentException("parameter ifserviceid '" + ifServiceIdString + "' is not an integer"); } OnmsMonitoredService service = m_monitoredServiceDao.get(ifServiceId); if (service == null) { throw new IllegalArgumentException("monitored service with " + "id of " + ifServiceId + " could not be found"); } return service; }
/** {@inheritDoc} */ @Override public List<OnmsApplication> findByMonitoredService(int id) { OnmsMonitoredService service = m_monitoredServiceDao.get(id); if (service == null) { throw new IllegalArgumentException("monitored service with " + "id of " + id + " could not be found"); } List<OnmsApplication> sortedApplications = new ArrayList<OnmsApplication>(service.getApplications()); Collections.sort(sortedApplications); return sortedApplications; }
private OnmsMonitoredService findService(String ifServiceIdString) { int ifServiceId; try { ifServiceId = WebSecurityUtils.safeParseInt(ifServiceIdString); } catch (NumberFormatException e) { throw new IllegalArgumentException("parameter ifserviceid '" + ifServiceIdString + "' is not an integer"); } OnmsMonitoredService service = m_monitoredServiceDao.get(ifServiceId); if (service == null) { throw new IllegalArgumentException("monitored service with " + "id of " + ifServiceId + " could not be found"); } return service; }
@Override public void updateServiceStatus(int nodeId, String ipAddr, String serviceName, String status) { try { OnmsMonitoredService service = m_monitoredServiceDao.get(nodeId, InetAddress.getByName(ipAddr), serviceName); service.setStatus(status); m_monitoredServiceDao.saveOrUpdate(service); } catch (UnknownHostException e) { LOG.error("Failed to set the status for service named {} on node id {} and interface {} to {}.", serviceName, nodeId, ipAddr, status, e); } }
String svcStatus = m_monitoredServiceDao.get((int)nodeid, ip, svcName).getStatus();
/** {@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 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(); }
OnmsMonitoredService service = monitoredServiceDao.get(Integer.valueOf(result[1]), InetAddressUtils.addr(criticalPathIp), criticalPathServiceName);
+ "' is not an integer"); OnmsMonitoredService service = m_monitoredServiceDao.get(id); if (service == null) { throw new IllegalArgumentException("monitored service with " + "' is not an integer"); OnmsMonitoredService service = m_monitoredServiceDao.get(id); if (service == null) { throw new IllegalArgumentException("monitored service with "
monSvc = m_monSvcDao.get(serviceId); } catch (final Exception e) { LOG.warn("Unable to report result for location monitor ID {}, monitored service ID {}: Monitored service does not exist.", locationMonitorId, serviceId, e);
monSvc = m_monSvcDao.get(serviceId); } catch (final Exception e) { LOG.warn("Unable to report result for location monitor ID {}, monitored service ID {}: Monitored service does not exist.", locationMonitorId, serviceId, e);
private OnmsMonitoredService toMonitoredService(MockService svc) { return m_monitoredServiceDao.get(svc.getNodeId(), svc.getAddress(), svc.getSvcName()); } }
LOG.debug("deleteService: nodeId={}, addr={}, service={}", nodeId, addr, svcName); final OnmsMonitoredService service = m_monitoredServiceDao.get(nodeId, addr, svcName); if (service != null) {
LOG.debug("deleteService: nodeId={}, addr={}, service={}", nodeId, addr, svcName); final OnmsMonitoredService service = m_monitoredServiceDao.get(nodeId, addr, svcName); if (service != null) {
public SimpleTestHierarchy(DatabasePopulator databasePopulator) { Objects.requireNonNull(databasePopulator); // Create a simple hierarchy BusinessServiceEntity child1 = new BusinessServiceEntityBuilder() .name("Child 1") .addIpService(databasePopulator.getMonitoredServiceDao().get(databasePopulator.getNode1().getId(), InetAddressUtils.addr("192.168.1.1"), "SNMP"), new IdentityEntity()) .reduceFunction(new HighestSeverityEntity()) .toEntity(); BusinessServiceEntity child2 = new BusinessServiceEntityBuilder() .name("Child 2") .addIpService(databasePopulator.getMonitoredServiceDao().get(databasePopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP"), new IdentityEntity()) .reduceFunction(new HighestSeverityEntity()) .toEntity(); BusinessServiceEntity root = new BusinessServiceEntityBuilder() .name("Parent") .addChildren(child1, new IdentityEntity()) .addChildren(child2, new IdentityEntity()) .reduceFunction(new HighestSeverityEntity()) .toEntity(); businessServices.add(child1); businessServices.add(child2); businessServices.add(root); }
public BusinessServicesShareIpServiceHierarchy(DatabasePopulator databasePopulator) { Objects.requireNonNull(databasePopulator); OnmsMonitoredService icmpServiceNode2 = databasePopulator.getMonitoredServiceDao().get( databasePopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP"); // Create a simple hierarchy BusinessServiceEntity child1 = new BusinessServiceEntityBuilder() .name("Child 1") .addIpService(icmpServiceNode2, new IdentityEntity()) .reduceFunction(new HighestSeverityEntity()) .toEntity(); BusinessServiceEntity child2 = new BusinessServiceEntityBuilder() .name("Child 2") .addIpService(icmpServiceNode2, new IdentityEntity()) .reduceFunction(new HighestSeverityEntity()) .toEntity(); BusinessServiceEntity root = new BusinessServiceEntityBuilder() .name("Parent") .addChildren(child1, new IdentityEntity()) .addChildren(child2, new IdentityEntity()) .reduceFunction(new HighestSeverityEntity()) .toEntity(); businessServices.add(child1); businessServices.add(child2); businessServices.add(root); }
/** * Retrieves all of the outages (using DAOs) associated with * the given service. */ private List<OnmsOutage> getOutages(MockService svc) { OnmsMonitoredService monitoredSvc = m_monitoredServiceDao.get( svc.getNodeId(), svc.getAddress(), svc.getSvcName()); Criteria criteria = new CriteriaBuilder(OnmsOutage.class) .eq("monitoredService", monitoredSvc) .orderBy("ifLostService") .toCriteria(); return m_outageDao.findMatching(criteria); }
/** * Test for NMS-7426. */ @Test public void testServicesWithoutPackagesAreMarkedAsNotPolled() { MockService monitoredSvc = m_network.getService(5, "192.168.1.7", "SNMP"); MockService notMonitoredSvc = m_network.getService(5, "192.168.1.7", "NotMonitored"); OnmsMonitoredService notMonitored = m_monitoredServiceDao.get( notMonitoredSvc.getNodeId(), notMonitoredSvc.getAddress(), notMonitoredSvc.getSvcName()); // The status should be set initially set to active assertEquals("A", notMonitored.getStatus()); // Start the poller startDaemons(); // Take a service down, and wait for the event // We do this to make ensure the nodes services we're in fact scheduled anticipateDown(monitoredSvc); monitoredSvc.bringDown(); verifyAnticipated(10000); // The status should now be set to not monitored notMonitored = m_monitoredServiceDao.get( notMonitoredSvc.getNodeId(), notMonitoredSvc.getAddress(), notMonitoredSvc.getSvcName()); assertEquals("N", notMonitored.getStatus()); }