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;
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class DefaultPollService method getServiceMonitor.
private ServiceMonitor getServiceMonitor(PolledService polledService) {
Assert.notNull(m_monitors, "setServiceMonitorLocators must be called before any other operations");
ServiceMonitor monitor = (ServiceMonitor) m_monitors.get(polledService.getSvcName());
// Assert.notNull(monitor, "Unable to find monitor for service "+polledService.getSvcName());
return monitor;
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class RadiusAuthMonitorTest method testResponses.
@Test
public void testResponses() throws Exception {
mockSrv.start(true, false);
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new RadiusAuthMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, InetAddressUtils.addr("127.0.0.1"), "RADIUS");
m.put("user", "testing");
m.put("password", "password");
m.put("retry", "1");
m.put("secret", "testing123");
m.put("authtype", "chap");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
Aggregations