Search in sources :

Example 11 with SshClient

use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.

the class NxosTelemetryIT method verifyNxosTelemetryOnMinion.

@Test
public void verifyNxosTelemetryOnMinion() 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 NXOS");
        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 = addRequisition(opennmsHttp, true, startOfTest);
    final InetSocketAddress minionUdp = m_testEnvironment.getServiceAddress(ContainerAlias.MINION, 50000, "udp");
    sendNxosTelemetryMessage(minionUdp);
    await().atMost(2, MINUTES).pollDelay(0, SECONDS).pollInterval(15, SECONDS).until(matchRrdFileFromNodeResource(onmsNode.getId()));
}
Also used : PrintStream(java.io.PrintStream) OnmsNode(org.opennms.netmgt.model.OnmsNode) SshClient(org.opennms.test.system.api.utils.SshClient) InetSocketAddress(java.net.InetSocketAddress) Date(java.util.Date) Test(org.junit.Test)

Example 12 with SshClient

use of org.opennms.test.system.api.utils.SshClient in project opennms by OpenNMS.

the class AbstractSyslogTestCase method resetRouteStatistics.

protected static void resetRouteStatistics(InetSocketAddress opennmsSshAddr, InetSocketAddress minionSshAddr) throws Exception {
    // Reset route statistics on Minion
    try (final SshClient sshClient = new SshClient(minionSshAddr, "admin", "admin")) {
        PrintStream pipe = sshClient.openShell();
        // Syslog listener
        pipe.println("camel:route-reset-stats syslogListen");
        pipe.println("logout");
        try {
            await().atMost(2, MINUTES).until(sshClient.isShellClosedCallable());
        } finally {
            LOG.info("Karaf output:\n{}", sshClient.getStdout());
        }
    }
    // Reset route statistics on OpenNMS
    try (final SshClient sshClient = new SshClient(opennmsSshAddr, "admin", "admin")) {
        PrintStream pipe = sshClient.openShell();
        // Elasticsearch forwarder
        pipe.println("camel:route-reset-stats alarmsFromOpennms");
        pipe.println("camel:route-reset-stats enrichAlarmsAndEvents");
        pipe.println("camel:route-reset-stats eventsFromOpennms");
        pipe.println("camel:route-reset-stats toElasticsearch");
        pipe.println("camel:route-reset-stats updateElastisearchTemplateMappingRunOnlyOnce");
        pipe.println("logout");
        try {
            await().atMost(2, MINUTES).until(sshClient.isShellClosedCallable());
        } finally {
            LOG.info("Karaf output:\n{}", sshClient.getStdout());
        }
    }
}
Also used : PrintStream(java.io.PrintStream) SshClient(org.opennms.test.system.api.utils.SshClient)

Aggregations

PrintStream (java.io.PrintStream)12 SshClient (org.opennms.test.system.api.utils.SshClient)12 ArrayList (java.util.ArrayList)3 InetSocketAddress (java.net.InetSocketAddress)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 HashMap (java.util.HashMap)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1