use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class SSLCertMonitorIT method testHostNameVerificationSucceeds.
@Test
@JUnitHttpServer(port = 10342, https = true, vhosts = "test.example.com")
public void testHostNameVerificationSucceeds() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 5);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
parameters.put("server-name", "${nodelabel}.example.com");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "test", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isAvailable());
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class SSLCertMonitorIT method testValidDateForCertificate.
@Test
@JUnitHttpServer(port = 10342, https = true)
public void testValidDateForCertificate() throws UnknownHostException {
SSLCertMonitor monitor = new SSLCertMonitor() {
@Override
protected Calendar getCalendarInstance() {
final Calendar cal = GregorianCalendar.getInstance();
cal.setTimeInMillis(EXPIRE_DATE - 86400000 * 5);
return cal;
}
};
Map<String, Object> parameters = new ConcurrentSkipListMap<String, Object>();
parameters.put("port", "10342");
parameters.put("retry", "0");
parameters.put("timeout", "500");
parameters.put("verbose", "true");
parameters.put("days", "5");
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost", false), "SSLCert");
PollStatus status = monitor.poll(svc, parameters);
assertTrue(status.isAvailable());
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithInvalidRegexpBanner.
@Test
public void testPollWithInvalidRegexpBanner() throws UnknownHostException, PatternSyntaxException {
ServiceMonitor sm = new SshMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.addr(HOST_TO_TEST), "SSH");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("banner", "^SSH\\-2\\.0\\-OpenSSH_\\d+\\.\\d+\\g$");
PollStatus ps = sm.poll(svc, parms);
assertTrue(ps.isUnavailable());
assertTrue(createAssertMessage(ps, "Unavailable"), ps.isUnavailable());
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class SshMonitorIT method testPollWithMatch.
@Test
public void testPollWithMatch() throws UnknownHostException {
ServiceMonitor sm = new SshMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.addr(HOST_TO_TEST), "SSH");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("match", "SSH");
PollStatus ps = sm.poll(svc, parms);
assertTrue(createAssertMessage(ps, "Up"), ps.isUp());
assertFalse(createAssertMessage(ps, "not Down"), ps.isDown());
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class SshMonitorIT method testPoll.
@Test
public void testPoll() throws UnknownHostException {
ServiceMonitor sm = new SshMonitor();
MonitoredService svc = new MockMonitoredService(1, "Router", InetAddressUtils.addr(HOST_TO_TEST), "SSH");
Map<String, Object> parms = new HashMap<String, Object>();
PollStatus ps = sm.poll(svc, parms);
assertTrue(createAssertMessage(ps, "Up"), ps.isUp());
assertFalse(createAssertMessage(ps, "not Down"), ps.isDown());
}
Aggregations