use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class HttpCollector method initHttpCollectionConfig.
private static void initHttpCollectionConfig() {
try {
LOG.debug("initialize: Initializing collector: {}", HttpCollector.class.getSimpleName());
HttpCollectionConfigFactory.init();
} catch (FileNotFoundException e) {
LOG.error("initialize: Error locating configuration.", e);
throw new UndeclaredThrowableException(e);
} catch (IOException e) {
LOG.error("initialize: Error reading configuration", e);
throw new UndeclaredThrowableException(e);
}
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class SmtpMonitorIT method testPollSvrStatus554.
@Test
public void testPollSvrStatus554() throws UnknownHostException, InterruptedException {
m_serverThread = new Thread(new Runnable() {
@Override
public void run() {
try {
m_serverSocket.setSoTimeout(1000);
Socket s = m_serverSocket.accept();
System.out.println("S: 554 localhost.localdomain ESMTP bogon");
s.getOutputStream().write("554 localhost.localdomain ESMTP bogon\r\n".getBytes());
BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
String command = r.readLine();
System.out.println("C: " + command);
if (command.equals("QUIT")) {
System.out.println("S: 221-Goodbye, friend.");
s.getOutputStream().write("221-Goodbye, friend.\r\n".getBytes());
System.out.println("S: 221 See ya");
s.getOutputStream().write("221 See ya\r\n".getBytes());
}
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
}
});
m_serverThread.start();
ServiceMonitor sm = new SmtpMonitor();
MonitoredService svc = new MockMonitoredService(1, "Node One", InetAddressUtils.addr("127.0.0.1"), "SMTP");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("port", m_serverSocket.getLocalPort());
PollStatus ps = sm.poll(svc, parms);
assertTrue(ps.isUnavailable());
assertFalse(ps.isUp());
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class SmtpMonitorIT method testPollCase1.
@Test
public void testPollCase1() throws UnknownHostException, InterruptedException {
m_serverThread = new Thread(new Runnable() {
@Override
public void run() {
try {
m_serverSocket.setSoTimeout(1000);
Socket s = m_serverSocket.accept();
System.out.println("S: 220-localhost.localdomain ESMTP bogon");
s.getOutputStream().write("220-localhost.localdomain ESMTP bogon\r\n".getBytes());
System.out.println("S: 220-send me mail soon!");
s.getOutputStream().write("220-send me mail soon!\r\n".getBytes());
System.out.println("S: 220 send me mail now!");
s.getOutputStream().write("220 send me mail now!\r\n".getBytes());
BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
String command = r.readLine();
System.out.println("C: " + command);
if (command.startsWith("HELO ")) {
System.out.println("S: 250 Hello");
s.getOutputStream().write("250 Hello\r\n".getBytes());
}
command = r.readLine();
System.out.println("C: " + command);
if (command.equals("QUIT")) {
System.out.println("S: 250 Hello");
s.getOutputStream().write("221 See ya\r\n".getBytes());
}
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
}
});
m_serverThread.start();
ServiceMonitor sm = new SmtpMonitor();
MonitoredService svc = new MockMonitoredService(1, "Node One", InetAddressUtils.addr("127.0.0.1"), "SMTP");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("port", m_serverSocket.getLocalPort());
PollStatus ps = sm.poll(svc, parms);
assertTrue(ps.isUp());
assertFalse(ps.isDown());
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class PercDetector method isServiceDetected.
/**
* {@inheritDoc}
*
* Returns true if the protocol defined by this plugin is supported. If
* the protocol is not supported then a false value is returned to the
* caller. The qualifier map passed to the method is used by the plugin to
* return additional information by key-name. These key-value pairs can be
* added to service events if needed.
*/
@Override
public boolean isServiceDetected(final InetAddress address, final SnmpAgentConfig agentConfig) {
try {
configureAgentPTR(agentConfig);
configureAgentVersion(agentConfig);
SnmpObjId snmpObjectId = SnmpObjId.get(LOGICAL_BASE_OID + '.' + m_arrayNumber);
SnmpValue value = SnmpUtils.get(agentConfig, snmpObjectId);
if (value.toInt() != 2) {
LOG.debug("PercMonitor.poll: Bad Disk Found. Log vol({}) degraded", m_arrayNumber);
return false;
}
} catch (Throwable t) {
throw new UndeclaredThrowableException(t);
}
return true;
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class SnmpDetector method isServiceDetected.
@Override
public boolean isServiceDetected(InetAddress address, SnmpAgentConfig agentConfig) {
try {
configureAgentPTR(agentConfig);
configureAgentVersion(agentConfig);
final String expectedValue = getVbvalue();
if (this.m_isTable) {
LOG.debug(getServiceName() + ": table detect enabled");
final SnmpObjId snmpObjId = SnmpObjId.get(getOid());
final Map<SnmpInstId, SnmpValue> table = SnmpUtils.getOidValues(agentConfig, DEFAULT_SERVICE_NAME, snmpObjId);
final List<String> retrievedValues = table.values().stream().map(snmpValue -> m_hex ? snmpValue.toHexString() : snmpValue.toString()).collect(Collectors.toList());
return isServiceDetected(this.matchType, retrievedValues, expectedValue);
} else {
final String retrievedValue = getValue(agentConfig, getOid(), m_hex);
// we have to ensure that if expectedValue is defined, we use ANY, this is due to backwards compatibility
MatchType matchType = this.matchType;
if (matchType == null && expectedValue != null) {
matchType = MatchType.Any;
}
return isServiceDetected(matchType, Lists.newArrayList(retrievedValue), expectedValue);
}
} catch (Throwable t) {
throw new UndeclaredThrowableException(t);
}
}
Aggregations