Search in sources :

Example 36 with ServiceMonitor

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;
}
Also used : ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor)

Example 37 with ServiceMonitor

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());
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Test(org.junit.Test)

Example 38 with ServiceMonitor

use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.

the class RadiusAuthMonitorTest method testTTLSResponse.

@Test
@Ignore("have to have a EAP-TTLS radius server set up")
public void testTTLSResponse() 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", "12");
    m.put("retry", "1");
    m.put("secret", "testing123");
    m.put("authtype", "eap-ttls");
    m.put("inner-user", "anonymous");
    final PollStatus status = monitor.poll(svc, m);
    MockUtil.println("Reason: " + status.getReason());
    System.out.println("Reason" + status.getReason());
    assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 39 with ServiceMonitor

use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.

the class RadiusAuthMonitorTest method testBadResponses.

@Test
public void testBadResponses() 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", "12");
    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_UNAVAILABLE, status.getStatusCode());
    MockLogAppender.assertLogMatched(Level.DEBUG, "response returned, but request was not accepted");
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Test(org.junit.Test)

Example 40 with ServiceMonitor

use of org.opennms.netmgt.poller.ServiceMonitor in project opennms by OpenNMS.

the class RadiusAuthMonitorTest method testTimeOut.

@Test
public void testTimeOut() throws Exception {
    // do not start raddius server
    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", "12");
    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_UNAVAILABLE, status.getStatusCode());
    MockLogAppender.assertLogMatched(Level.DEBUG, "Error while attempting to connect to the RADIUS service on localhost");
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Test(org.junit.Test)

Aggregations

ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)58 PollStatus (org.opennms.netmgt.poller.PollStatus)53 MonitoredService (org.opennms.netmgt.poller.MonitoredService)50 Test (org.junit.Test)36 MockMonitoredService (org.opennms.netmgt.poller.mock.MockMonitoredService)32 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)25 HashMap (java.util.HashMap)24 Parameter (org.opennms.netmgt.config.poller.Parameter)7 BufferedReader (java.io.BufferedReader)6 InputStreamReader (java.io.InputStreamReader)6 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)6 ServerSocket (java.net.ServerSocket)6 Socket (java.net.Socket)6 InetAddress (java.net.InetAddress)3 List (java.util.List)3 Package (org.opennms.netmgt.config.poller.Package)3 Service (org.opennms.netmgt.config.poller.Service)3 SimpleMonitoredService (org.opennms.netmgt.poller.support.SimpleMonitoredService)3 Map (java.util.Map)2 Ignore (org.junit.Ignore)2