use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class TcpMonitorIT method testLocalhostIPv6Connection.
@Test
@JUnitHttpServer(port = 10342)
public void testLocalhostIPv6Connection() throws UnknownHostException {
assumeTrue(!Boolean.getBoolean("skipIpv6Tests"));
Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
Parameter p = new Parameter();
ServiceMonitor monitor = new TcpMonitor();
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "::1", addr("::1"), "TCP");
p.setKey("port");
p.setValue("10342");
m.put(p.getKey(), p.getValue());
p.setKey("retry");
p.setValue("1");
m.put(p.getKey(), p.getValue());
p.setKey("timeout");
p.setValue("500");
m.put(p.getKey(), p.getValue());
PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
assertNull(status.getReason());
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class PollerConfigManager method getServiceMonitorLocators.
/**
* {@inheritDoc}
*/
@Override
public Collection<ServiceMonitorLocator> getServiceMonitorLocators(final DistributionContext context) {
List<ServiceMonitorLocator> locators = new ArrayList<ServiceMonitorLocator>();
try {
getReadLock().lock();
for (final Monitor monitor : monitors()) {
try {
final Class<? extends ServiceMonitor> mc = findServiceMonitorClass(monitor);
if (isDistributableToContext(mc, context)) {
final ServiceMonitorLocator locator = new DefaultServiceMonitorLocator(monitor.getService(), mc);
locators.add(locator);
}
LOG.debug("Loaded monitor for service: {}, class-name: {}", monitor.getService(), monitor.getClassName());
} catch (final ClassNotFoundException e) {
LOG.warn("Unable to load monitor for service: {}, class-name: {}: {}", monitor.getService(), monitor.getClassName(), e.getMessage());
} catch (ConfigObjectRetrievalFailureException e) {
LOG.warn("{} {}", e.getMessage(), e.getRootCause(), e);
}
}
} finally {
getReadLock().unlock();
}
return locators;
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class AvailabilityMonitorTest method testPoll.
/**
* Test method for {@link org.opennms.netmgt.poller.support.AvailabilityMonitor#poll(org.opennms.netmgt.poller.MonitoredService, Map)}.
*/
@Test
public final void testPoll() {
ServiceMonitor sm = new AvailabilityMonitor();
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("timeout", "3000");
MonitoredService svc = new SimpleMonitoredService(InetAddressUtils.addr("127.0.0.1"), "ICMP");
PollStatus status = sm.poll(svc, parameters);
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class DefaultPollService method poll.
/**
* {@inheritDoc}
*/
@Override
public PollStatus poll(PolledService polledService) {
ServiceMonitor monitor = getServiceMonitor(polledService);
if (monitor == null) {
return PollStatus.unknown("No service monitor for service " + polledService.getSvcName());
} else {
PollStatus result = monitor.poll(polledService, polledService.getMonitorConfiguration());
result.setTimestamp(m_timeAdjustment.adjustDateToMasterDate(result.getTimestamp()));
return result;
}
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class DefaultPollService method setServiceMonitorLocators.
/**
* {@inheritDoc}
*/
@Override
public void setServiceMonitorLocators(Collection<ServiceMonitorLocator> locators) {
Map<String, ServiceMonitor> monitors = new HashMap<String, ServiceMonitor>();
for (ServiceMonitorLocator locator : locators) {
monitors.put(locator.getServiceName(), locator.getServiceMonitor(s_serviceMonitorRegistry));
}
m_monitors = monitors;
}
Aggregations