Search in sources :

Example 66 with OnmsMonitoredService

use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.

the class BusinessServiceManagerImpl method getMonitoredServiceEntity.

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;
}
Also used : NoSuchElementException(java.util.NoSuchElementException) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 67 with OnmsMonitoredService

use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.

the class OutageStatusCalculatorIT method verifyCalculateStatus.

@Test
@Transactional
public void verifyCalculateStatus() {
    final OnmsNode node = databasePopulator.getNode1();
    final OnmsMonitoredService icmpService = node.getIpInterfaceByIpAddress("192.168.1.1").getMonitoredServiceByServiceType("ICMP");
    final OnmsMonitoredService snmpService = node.getIpInterfaceByIpAddress("192.168.1.1").getMonitoredServiceByServiceType("SNMP");
    final GeolocationQuery query = new GeolocationQueryBuilder().build();
    final StatusCalculator statusCalculator = new OutageStatusCalculator(genericPersistenceAccessor);
    final Set<Integer> nodeIds = Sets.newHashSet(node.getId());
    // No outage exist, status should be normal
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
    // Create an alarm and verify status
    final OnmsOutage outage = createOutage(icmpService, createEvent(node, OnmsSeverity.WARNING));
    saveOrUpdate(outage);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.WARNING), statusCalculator.calculateStatus(query, nodeIds));
    // Create another outage on same interface and verify
    final OnmsOutage outage2 = createOutage(snmpService, createEvent(node, OnmsSeverity.MINOR));
    saveOrUpdate(outage2);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
    // Create another outage on another interface and verify
    final OnmsMonitoredService httpService = node.getIpInterfaceByIpAddress("192.168.1.2").getMonitoredServiceByServiceType("HTTP");
    saveOrUpdate(createOutage(httpService, createEvent(node, OnmsSeverity.MAJOR)));
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    // Create another outage on another node and verify
    saveOrUpdate(createOutage(databasePopulator.getNode2().getPrimaryInterface().getMonitoredServiceByServiceType("ICMP"), createEvent(databasePopulator.getNode2(), OnmsSeverity.CRITICAL)));
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    // calculate status for both
    verifyStatus(2, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR, databasePopulator.getNode2().getId(), OnmsSeverity.CRITICAL), statusCalculator.calculateStatus(query, Sets.newHashSet(node.getId(), databasePopulator.getNode2().getId())));
    // Resolve the Warning Outage
    outage.setServiceRegainedEvent(createEvent(node, OnmsSeverity.WARNING));
    outage.setIfRegainedService(new Date());
    saveOrUpdate(outage);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    // Apply severity filter
    query.setSeverity(GeolocationSeverity.Warning);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setSeverity(GeolocationSeverity.Minor);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setSeverity(GeolocationSeverity.Major);
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setSeverity(GeolocationSeverity.Critical);
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
    // reset severity filter and apply location filter
    query.setSeverity(null);
    query.setLocation(distPollerDao.whoami().getLocation());
    verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MAJOR), statusCalculator.calculateStatus(query, nodeIds));
    query.setLocation("XXX");
    verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) OnmsNode(org.opennms.netmgt.model.OnmsNode) GeolocationQueryBuilder(org.opennms.features.geolocation.api.GeolocationQueryBuilder) GeolocationQuery(org.opennms.features.geolocation.api.GeolocationQuery) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 68 with OnmsMonitoredService

use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.

the class PollerTest method getIPv6MonitoredService.

private OnmsMonitoredService getIPv6MonitoredService() {
    OnmsNode node = new OnmsNode();
    OnmsMonitoringLocation location = new OnmsMonitoringLocation();
    location.setLocationName("MINION");
    node.setId(1);
    node.setLocation(location);
    OnmsIpInterface iface = new OnmsIpInterface("::1", node);
    // Make sure that the address is being converted into fully-qualified format
    assertEquals("0000:0000:0000:0000:0000:0000:0000:0001", str(iface.getIpAddress()));
    OnmsServiceType svcType = new OnmsServiceType("HTTP");
    OnmsMonitoredService svc = new OnmsMonitoredService(iface, svcType);
    return svc;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 69 with OnmsMonitoredService

use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.

the class PollerTest method getMonitoredService.

private OnmsMonitoredService getMonitoredService() {
    OnmsNode node = new OnmsNode();
    OnmsMonitoringLocation location = new OnmsMonitoringLocation();
    location.setLocationName("MINION");
    node.setId(1);
    node.setLocation(location);
    OnmsIpInterface iface = new OnmsIpInterface("192.168.1.1", node);
    OnmsServiceType svcType = new OnmsServiceType("HTTP");
    OnmsMonitoredService svc = new OnmsMonitoredService(iface, svcType);
    return svc;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 70 with OnmsMonitoredService

use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.

the class DefaultPollerBackEnd method createPollerConfiguration.

private SimplePollerConfiguration createPollerConfiguration(String pollingPackageName) {
    final Package pkg = getPollingPackage(pollingPackageName);
    final ServiceSelector selector = m_pollerConfig.getServiceSelectorForPackage(pkg);
    final Collection<OnmsMonitoredService> services = m_monSvcDao.findMatchingServices(selector);
    final List<PolledService> configs = new ArrayList<PolledService>(services.size());
    LOG.debug("Found {} services in polling package {}", services.size(), pollingPackageName);
    for (final OnmsMonitoredService monSvc : services) {
        final Service serviceConfig = m_pollerConfig.getServiceInPackage(monSvc.getServiceName(), pkg);
        final long interval = serviceConfig.getInterval();
        final Map<String, Object> parameters = getParameterMap(serviceConfig);
        if (LOG.isTraceEnabled()) {
            for (Map.Entry<String, Object> entry : parameters.entrySet()) {
                LOG.trace("Service {} has parameter {} with type {} and value: {}", monSvc.getServiceName(), entry.getKey(), entry.getValue() != null ? entry.getValue().getClass().getCanonicalName() : "null", entry.getValue());
            }
        }
        configs.add(new PolledService(monSvc, parameters, new OnmsPollModel(interval)));
    }
    Collections.sort(configs);
    return new SimplePollerConfiguration(getConfigurationTimestamp(), configs.toArray(new PolledService[configs.size()]));
}
Also used : OnmsPollModel(org.opennms.netmgt.poller.remote.OnmsPollModel) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) ArrayList(java.util.ArrayList) PolledService(org.opennms.netmgt.poller.remote.PolledService) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Service(org.opennms.netmgt.config.poller.Service) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) PolledService(org.opennms.netmgt.poller.remote.PolledService) Package(org.opennms.netmgt.config.poller.Package) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)119 Date (java.util.Date)37 OnmsNode (org.opennms.netmgt.model.OnmsNode)36 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)33 Test (org.junit.Test)27 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)25 Transactional (org.springframework.transaction.annotation.Transactional)22 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)20 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)18 ArrayList (java.util.ArrayList)17 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)17 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)15 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)15 LinkedList (java.util.LinkedList)13 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)13 HashSet (java.util.HashSet)9 Before (org.junit.Before)6 Criteria (org.opennms.core.criteria.Criteria)5 BusinessServiceEntity (org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity)5 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)5