Search in sources :

Example 56 with PollStatus

use of org.opennms.netmgt.poller.PollStatus 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());
}
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 57 with PollStatus

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

the class DiskUsageMonitorTest method testInvalidMatchTypeParameter.

@Test(expected = RuntimeException.class)
public void testInvalidMatchTypeParameter() throws Exception {
    Map<String, Object> parameters = createBasicParams();
    parameters.put("match-type", "invalid");
    PollStatus status = monitor.poll(createMonitor(), parameters);
    Assert.assertFalse(status.isAvailable());
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Test(org.junit.Test)

Example 58 with PollStatus

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

the class DiskUsageMonitorTest method testInvalidDiskRegex.

@Test
public void testInvalidDiskRegex() throws Exception {
    Map<String, Object> parameters = createBasicParams();
    parameters.put("disk", "^[A-Z:");
    parameters.put("match-type", "regex");
    PollStatus status = monitor.poll(createMonitor(), parameters);
    Assert.assertFalse(status.isAvailable());
    Assert.assertThat(status.getReason(), containsString("Invalid SNMP Criteria: Unclosed character class"));
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Test(org.junit.Test)

Example 59 with PollStatus

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

the class DiskUsageMonitorTest method testAllDisks.

@Test
public void testAllDisks() throws Exception {
    Map<String, Object> parameters = createBasicParams();
    parameters.put("match-type", "startswith");
    parameters.put("require-type", "all");
    PollStatus status = monitor.poll(createMonitor(), parameters);
    Assert.assertFalse(status.isAvailable());
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Test(org.junit.Test)

Example 60 with PollStatus

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

the class LocationDataServiceIT method getAvailable.

private PollStatus getAvailable(final Date date) {
    final PollStatus ps = PollStatus.available();
    ps.setTimestamp(date);
    return ps;
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus)

Aggregations

PollStatus (org.opennms.netmgt.poller.PollStatus)209 Test (org.junit.Test)98 MonitoredService (org.opennms.netmgt.poller.MonitoredService)57 ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)53 InetAddress (java.net.InetAddress)40 HashMap (java.util.HashMap)36 MockMonitoredService (org.opennms.netmgt.poller.mock.MockMonitoredService)36 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)32 TimeoutTracker (org.opennms.core.utils.TimeoutTracker)29 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)18 IOException (java.io.IOException)17 Socket (java.net.Socket)17 InputStreamReader (java.io.InputStreamReader)16 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)14 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)14 BufferedReader (java.io.BufferedReader)13 SnmpObjId (org.opennms.netmgt.snmp.SnmpObjId)12 InterruptedIOException (java.io.InterruptedIOException)11 ConnectException (java.net.ConnectException)11 NoRouteToHostException (java.net.NoRouteToHostException)11