use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class DnsMonitorIT method testDNSIPV4Response.
@Test
public void testDNSIPV4Response() throws UnknownHostException {
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new DnsMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, addr("127.0.0.1"), "DNS");
m.put("port", "9153");
m.put("retry", "1");
m.put("timeout", "3000");
m.put("lookup", "example.com");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class DnsMonitorIT method testIPV6Response.
@Test
public void testIPV6Response() throws UnknownHostException {
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new DnsMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, addr("::1"), "DNS");
m.put("port", "9153");
m.put("retry", "1");
m.put("timeout", "1000");
m.put("lookup", "ipv6.example.com");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class PollerClientRpcModule method execute.
@Override
public CompletableFuture<PollerResponseDTO> execute(PollerRequestDTO request) {
final String className = request.getClassName();
final ServiceMonitor monitor = serviceMonitorRegistry.getMonitorByClassName(className);
if (monitor == null) {
return CompletableFuture.completedFuture(new PollerResponseDTO(PollStatus.unknown("No monitor found with class name '" + className + "'.")));
}
return CompletableFuture.supplyAsync(new Supplier<PollerResponseDTO>() {
@Override
public PollerResponseDTO get() {
PollStatus pollStatus;
try {
final Map<String, Object> parameters = request.getMonitorParameters();
pollStatus = monitor.poll(request, parameters);
} catch (RuntimeException e) {
pollStatus = PollStatus.unknown(e.getMessage());
}
return new PollerResponseDTO(pollStatus);
}
}, executor);
}
use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.
the class RadiusAuthMonitorTest method testResponse.
@Test
@Ignore("have to have a radius server set up")
public void testResponse() throws Exception {
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new RadiusAuthMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, InetAddressUtils.addr("192.168.211.11"), "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());
}
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());
}
Aggregations