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;
}
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));
}
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;
}
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;
}
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()]));
}
Aggregations