Search in sources :

Example 1 with TelemetrydConfiguration

use of org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration in project opennms by OpenNMS.

the class Telemetryd method start.

@Override
public synchronized void start() throws Exception {
    if (consumers.size() > 0) {
        throw new IllegalStateException(NAME + " is already started.");
    }
    LOG.info("{} is starting.", NAME);
    final TelemetrydConfiguration config = telemetrydConfigDao.getContainer().getObject();
    final AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
    for (Protocol protocol : config.getProtocols()) {
        if (!protocol.getEnabled()) {
            LOG.debug("Skipping disabled protocol: {}", protocol.getName());
            continue;
        }
        LOG.debug("Setting up protocol: {}", protocol.getName());
        // Create a Sink module using the protocol definition.
        // This allows for protocol to each have their respective queues and thread
        // related settings to help limit the impact of one protocol on another.
        final TelemetrySinkModule sinkModule = new TelemetrySinkModule(protocol);
        beanFactory.autowireBean(sinkModule);
        beanFactory.initializeBean(sinkModule, "sinkModule");
        // Create the consumer, but don't start it yet
        final TelemetryMessageConsumer consumer = new TelemetryMessageConsumer(protocol, sinkModule);
        beanFactory.autowireBean(consumer);
        beanFactory.initializeBean(consumer, "consumer");
        consumers.add(consumer);
        // Build the dispatcher, and all of
        final AsyncDispatcher<TelemetryMessage> dispatcher = messageDispatcherFactory.createAsyncDispatcher(sinkModule);
        dispatchers.add(dispatcher);
        for (org.opennms.netmgt.telemetry.config.model.Listener listenerDef : protocol.getListeners()) {
            listeners.add(ListenerFactory.buildListener(listenerDef, dispatcher));
        }
    }
    // Start the consumers
    for (TelemetryMessageConsumer consumer : consumers) {
        LOG.info("Starting consumer for {} protocol.", consumer.getProtocol().getName());
        messageConsumerManager.registerConsumer(consumer);
    }
    // Start the listeners
    for (Listener listener : listeners) {
        LOG.info("Starting {} listener.", listener.getName());
        listener.start();
    }
    LOG.info("{} is started.", NAME);
}
Also used : TelemetrySinkModule(org.opennms.netmgt.telemetry.ipc.TelemetrySinkModule) Listener(org.opennms.netmgt.telemetry.listeners.api.Listener) EventListener(org.opennms.netmgt.events.api.annotations.EventListener) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory) TelemetryMessage(org.opennms.netmgt.telemetry.listeners.api.TelemetryMessage) TelemetrydConfiguration(org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration) Protocol(org.opennms.netmgt.telemetry.config.model.Protocol)

Example 2 with TelemetrydConfiguration

use of org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration in project opennms by OpenNMS.

the class TelemetrydConfigTest method data.

@Parameterized.Parameters
public static Collection<Object[]> data() throws ParseException, UnknownHostException {
    TelemetrydConfiguration telemetrydConfig = new TelemetrydConfiguration();
    Protocol jtiProtocol = new Protocol();
    jtiProtocol.setName("JTI");
    jtiProtocol.setDescription("Junos Telemetry Interface (JTI)");
    jtiProtocol.setEnabled(false);
    telemetrydConfig.getProtocols().add(jtiProtocol);
    Listener udpListener = new Listener();
    udpListener.setName("JTI-UDP-50000");
    udpListener.setClassName("org.opennms.netmgt.collection.streaming.udp.UdpListener");
    udpListener.getParameters().add(new Parameter("port", "50000"));
    jtiProtocol.getListeners().add(udpListener);
    Adapter jtiGbpAdapter = new Adapter();
    jtiGbpAdapter.setName("JTI-GPB");
    jtiGbpAdapter.setClassName("org.opennms.netmgt.collection.streaming.jti.JtiGpbAdapter");
    jtiGbpAdapter.getParameters().add(new Parameter("script", "${install.dir}/etc/telemetryd-adapters/junos-telemetry-interface.groovy"));
    jtiProtocol.getAdapters().add(jtiGbpAdapter);
    Package jtiDefaultPkg = new Package();
    jtiDefaultPkg.setName("JTI-Default");
    jtiDefaultPkg.setFilter(new Filter("IPADDR != '0.0.0.0'"));
    jtiProtocol.getPackages().add(jtiDefaultPkg);
    Rrd rrd = new Rrd();
    rrd.setStep(300);
    rrd.getRras().add("RRA:AVERAGE:0.5:1:2016");
    rrd.getRras().add("RRA:AVERAGE:0.5:12:1488");
    rrd.getRras().add("RRA:AVERAGE:0.5:288:366");
    rrd.getRras().add("RRA:MAX:0.5:288:366");
    rrd.getRras().add("RRA:MIN:0.5:288:366");
    jtiDefaultPkg.setRrd(rrd);
    return Arrays.asList(new Object[][] { { telemetrydConfig, "<telemetryd-config>\n" + "  <protocol name=\"JTI\" description=\"Junos Telemetry Interface (JTI)\" enabled=\"false\">\n" + "    <listener name=\"JTI-UDP-50000\" class-name=\"org.opennms.netmgt.collection.streaming.udp.UdpListener\">\n" + "      <parameter key=\"port\" value=\"50000\"/>\n" + "    </listener>\n" + "\n" + "    <adapter name=\"JTI-GPB\" class-name=\"org.opennms.netmgt.collection.streaming.jti.JtiGpbAdapter\">\n" + "      <parameter key=\"script\" value=\"${install.dir}/etc/telemetryd-adapters/junos-telemetry-interface.groovy\" />\n" + "    </adapter>\n" + "\n" + "    <package name=\"JTI-Default\">\n" + "      <filter>IPADDR != '0.0.0.0'</filter>\n" + "      <rrd step=\"300\">\n" + "        <rra>RRA:AVERAGE:0.5:1:2016</rra>\n" + "        <rra>RRA:AVERAGE:0.5:12:1488</rra>\n" + "        <rra>RRA:AVERAGE:0.5:288:366</rra>\n" + "        <rra>RRA:MAX:0.5:288:366</rra>\n" + "        <rra>RRA:MIN:0.5:288:366</rra>\n" + "      </rrd>\n" + "    </package>\n" + "  </protocol>\n" + "</telemetryd-config>" } });
}
Also used : TelemetrydConfiguration(org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration) Listener(org.opennms.netmgt.telemetry.config.model.Listener) Filter(org.opennms.netmgt.telemetry.config.model.Filter) Rrd(org.opennms.netmgt.telemetry.config.model.Rrd) Parameter(org.opennms.netmgt.telemetry.config.model.Parameter) Adapter(org.opennms.netmgt.telemetry.config.model.Adapter) Package(org.opennms.netmgt.telemetry.config.model.Package) Protocol(org.opennms.netmgt.telemetry.config.model.Protocol)

Example 3 with TelemetrydConfiguration

use of org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration in project opennms by OpenNMS.

the class JtiIT method getConfig.

private TelemetrydConfiguration getConfig(int port) {
    TelemetrydConfiguration telemetrydConfig = new TelemetrydConfiguration();
    Protocol jtiProtocol = new Protocol();
    jtiProtocol.setName("JTI");
    jtiProtocol.setDescription("Junos Telemetry Interface (JTI)");
    telemetrydConfig.getProtocols().add(jtiProtocol);
    Listener udpListener = new Listener();
    udpListener.setName("JTI-UDP-" + port);
    udpListener.setClassName(UdpListener.class.getCanonicalName());
    udpListener.getParameters().add(new Parameter("port", Integer.toString(port)));
    jtiProtocol.getListeners().add(udpListener);
    Adapter jtiGbpAdapter = new Adapter();
    jtiGbpAdapter.setName("JTI-GBP");
    jtiGbpAdapter.setClassName(JtiGpbAdapter.class.getCanonicalName());
    File script = Paths.get(System.getProperty("opennms.home"), "etc", "telemetryd-adapters", "junos-telemetry-interface.groovy").toFile();
    assertTrue("Can't read: " + script.getAbsolutePath(), script.canRead());
    jtiGbpAdapter.getParameters().add(new Parameter("script", script.getAbsolutePath()));
    jtiProtocol.getAdapters().add(jtiGbpAdapter);
    Package jtiDefaultPkg = new Package();
    jtiDefaultPkg.setName("JTI-Default");
    jtiDefaultPkg.setFilter(new Filter("IPADDR != '0.0.0.0'"));
    jtiProtocol.getPackages().add(jtiDefaultPkg);
    Rrd rrd = new Rrd();
    rrd.setStep(300);
    rrd.setBaseDir(rrdBaseDir.getAbsolutePath());
    rrd.getRras().add("RRA:AVERAGE:0.5:1:2016");
    jtiDefaultPkg.setRrd(rrd);
    return telemetrydConfig;
}
Also used : TelemetrydConfiguration(org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration) UdpListener(org.opennms.netmgt.telemetry.listeners.udp.UdpListener) Listener(org.opennms.netmgt.telemetry.config.model.Listener) UdpListener(org.opennms.netmgt.telemetry.listeners.udp.UdpListener) Filter(org.opennms.netmgt.telemetry.config.model.Filter) Rrd(org.opennms.netmgt.telemetry.config.model.Rrd) JtiGpbAdapter(org.opennms.netmgt.telemetry.adapters.jti.JtiGpbAdapter) Parameter(org.opennms.netmgt.telemetry.config.model.Parameter) Adapter(org.opennms.netmgt.telemetry.config.model.Adapter) JtiGpbAdapter(org.opennms.netmgt.telemetry.adapters.jti.JtiGpbAdapter) Package(org.opennms.netmgt.telemetry.config.model.Package) Protocol(org.opennms.netmgt.telemetry.config.model.Protocol) File(java.io.File)

Aggregations

Protocol (org.opennms.netmgt.telemetry.config.model.Protocol)3 TelemetrydConfiguration (org.opennms.netmgt.telemetry.config.model.TelemetrydConfiguration)3 Adapter (org.opennms.netmgt.telemetry.config.model.Adapter)2 Filter (org.opennms.netmgt.telemetry.config.model.Filter)2 Listener (org.opennms.netmgt.telemetry.config.model.Listener)2 Package (org.opennms.netmgt.telemetry.config.model.Package)2 Parameter (org.opennms.netmgt.telemetry.config.model.Parameter)2 Rrd (org.opennms.netmgt.telemetry.config.model.Rrd)2 File (java.io.File)1 EventListener (org.opennms.netmgt.events.api.annotations.EventListener)1 JtiGpbAdapter (org.opennms.netmgt.telemetry.adapters.jti.JtiGpbAdapter)1 TelemetrySinkModule (org.opennms.netmgt.telemetry.ipc.TelemetrySinkModule)1 Listener (org.opennms.netmgt.telemetry.listeners.api.Listener)1 TelemetryMessage (org.opennms.netmgt.telemetry.listeners.api.TelemetryMessage)1 UdpListener (org.opennms.netmgt.telemetry.listeners.udp.UdpListener)1 AutowireCapableBeanFactory (org.springframework.beans.factory.config.AutowireCapableBeanFactory)1