use of org.opennms.netmgt.telemetry.config.model.Protocol 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);
}
use of org.opennms.netmgt.telemetry.config.model.Protocol 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>" } });
}
use of org.opennms.netmgt.telemetry.config.model.Protocol 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;
}
Aggregations