use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.
the class MonitorsListCommandIT method listAndVerifyMonitors.
public List<String> listAndVerifyMonitors(String host, InetSocketAddress sshAddr) throws Exception {
List<String> unmatchedMonitors = new ArrayList<>();
try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) {
// List the monitors
PrintStream pipe = sshClient.openShell();
pipe.println("poller:list-monitors");
pipe.println("logout");
await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable());
// Parse the output
String shellOutput = CommandTestUtils.stripAnsiCodes(sshClient.getStdout());
shellOutput = StringUtils.substringAfter(shellOutput, "poller:list-monitors");
LOG.info("Monitors output: {}", shellOutput);
Set<String> monitors = new HashSet<>();
for (String monitor : shellOutput.split("\\r?\\n")) {
if (StringUtils.isNotBlank(monitor)) {
monitors.add(monitor);
}
}
LOG.info("Found monitors: {}", monitors);
// Verify
for (String monitorName : expectedMonitors) {
if (!monitors.contains(monitorName)) {
unmatchedMonitors.add(monitorName);
}
}
}
return unmatchedMonitors;
}
use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.
the class AlarmElasticsearch5IT method installElasticsearchFeaturesOnOpenNMS.
private static void installElasticsearchFeaturesOnOpenNMS(InetSocketAddress opennmsSshAddr) throws Exception {
try (final SshClient sshClient = new SshClient(opennmsSshAddr, "admin", "admin")) {
PrintStream pipe = sshClient.openShell();
// Configure and install the Elasticsearch REST event forwarder
pipe.println("config:edit org.opennms.plugin.elasticsearch.rest.forwarder");
// Retry enough times that all events are eventually sent
// even if transient ES outages occur
pipe.println("config:property-set retries 200");
pipe.println("config:update");
pipe.println("feature:install opennms-es-rest");
pipe.println("feature:install alarm-change-notifier");
pipe.println("feature:list -i");
// Set the log level to INFO
pipe.println("log:set INFO");
pipe.println("logout");
try {
await().atMost(2, MINUTES).until(sshClient.isShellClosedCallable());
} finally {
LOG.info("Karaf output:\n{}", sshClient.getStdout());
}
}
}
use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.
the class AbstractSyslogTestCase method installFeaturesOnMinion.
/**
* Install the Kafka features on Minion.
*
* @param minionSshAddr
* @param kafkaAddress
* @throws Exception
*/
protected static void installFeaturesOnMinion(InetSocketAddress minionSshAddr, InetSocketAddress kafkaAddress) throws Exception {
try (final SshClient sshClient = new SshClient(minionSshAddr, "admin", "admin")) {
PrintStream pipe = sshClient.openShell();
pipe.println("feature:list -i");
pipe.println("list");
// Set the log level to INFO
pipe.println("log:set INFO");
pipe.println("logout");
try {
await().atMost(2, MINUTES).until(sshClient.isShellClosedCallable());
} finally {
LOG.info("Karaf output:\n{}", sshClient.getStdout());
}
}
}
use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.
the class JMXCollectorIT method doCollect.
public String doCollect(InetSocketAddress sshAddr) throws Exception {
try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) {
// Perform an adhoc collection from against the Minion JVM
final PrintStream pipe = sshClient.openShell();
pipe.println("collection:collect -l MINION org.opennms.netmgt.collectd.Jsr160Collector 127.0.0.1 port=18980");
pipe.println("logout");
await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable());
// Sanitize the output
String shellOutput = CommandTestUtils.stripAnsiCodes(sshClient.getStdout());
shellOutput = StringUtils.substringAfter(shellOutput, "collection:collect");
LOG.info("Collect output: {}", shellOutput);
return shellOutput;
}
}
use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.
the class JtiTelemetryIT method verifyJtiTelemetryOnMinion.
@Test
public void verifyJtiTelemetryOnMinion() throws Exception {
Date startOfTest = new Date();
final InetSocketAddress sshAddr = m_testEnvironment.getServiceAddress(ContainerAlias.MINION, 8201);
try (final SshClient sshClient = new SshClient(sshAddr, "admin", "admin")) {
// Modify minion configuration for telemetry
PrintStream pipe = sshClient.openShell();
pipe.println("config:edit org.opennms.features.telemetry.listeners-udp-50000");
pipe.println("config:property-set name JTI");
pipe.println("config:property-set class-name org.opennms.netmgt.telemetry.listeners.udp.UdpListener");
pipe.println("config:property-set listener.port 50000");
pipe.println("config:update");
pipe.println("logout");
await().atMost(1, MINUTES).until(sshClient.isShellClosedCallable());
}
OnmsNode onmsNode = sendnewSuspectEvent(executor, opennmsHttp, m_testEnvironment, true, startOfTest);
final InetSocketAddress minionUdp = m_testEnvironment.getServiceAddress(ContainerAlias.MINION, 50000, "udp");
sendJtiTelemetryMessage(minionUdp);
await().atMost(2, MINUTES).pollDelay(0, SECONDS).pollInterval(15, SECONDS).until(matchRrdFileFromNodeResource(onmsNode.getId()));
}
Aggregations