use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.
the class TelemetryConfigListCommand method doExecute.
@Override
protected void doExecute() {
TelemetryConfigService service = get(TelemetryConfigService.class);
List<TelemetryConfig> configs = service.getConfigs().stream().filter(c -> !c.swVersion().equals(MASTER)).sorted(Comparator.comparing(TelemetryConfig::type)).collect(Collectors.toList());
print(FORMAT, "Name", "Type", "Enabled", "Manufacturer", "swVersion");
for (TelemetryConfig config : configs) {
print(FORMAT, config.name(), config.type(), config.status().name(), config.manufacturer(), config.swVersion());
}
}
use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.
the class TelemetryConfigNameCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
TelemetryConfigService service = get(TelemetryConfigService.class);
Set<String> set = service.getConfigs().stream().filter(c -> !c.swVersion().equals(MASTER)).sorted(Comparator.comparing(TelemetryConfig::name)).map(TelemetryConfig::name).collect(Collectors.toSet());
SortedSet<String> strings = delegate.getStrings();
strings.addAll(set);
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.
the class DefaultTelemetryConfig method getProperty.
@Override
public String getProperty(String name) {
Queue<TelemetryConfig> queue = new LinkedList<>();
queue.add(this);
while (!queue.isEmpty()) {
TelemetryConfig config = queue.remove();
String property = config.properties().get(name);
if (property != null) {
return property;
} else if (config.parents() != null) {
queue.addAll(config.parents());
}
}
return null;
}
use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.
the class RestTelemetryManager method publish.
@Override
public Set<Response> publish(String record) {
Set<Response> responses = Sets.newConcurrentHashSet();
targets.forEach((k, v) -> {
TelemetryConfig config = telemetryConfigService.getConfig(k);
RestTelemetryConfig restConfig = fromTelemetryConfig(config);
switch(restConfig.method()) {
case POST_METHOD:
responses.add(v.request(restConfig.requestMediaType()).post(Entity.json(record)));
break;
case GET_METHOD:
responses.add(v.request(restConfig.requestMediaType()).get());
break;
default:
break;
}
});
return responses;
}
use of org.onosproject.openstacktelemetry.api.config.TelemetryConfig in project onos by opennetworkinglab.
the class InfluxDbTelemetryManager method publish.
@Override
public void publish(InfluxRecord<String, Set<FlowInfo>> record) {
if (producers == null || producers.isEmpty()) {
log.debug("InfluxDB telemetry service has not been enabled!");
return;
}
if (record.flowInfos().size() == 0) {
log.debug("No record to publish");
return;
}
log.debug("Publish {} stats records to InfluxDB", record.flowInfos().size());
producers.forEach((k, v) -> {
TelemetryConfig config = telemetryConfigService.getConfig(k);
InfluxDbTelemetryConfig influxDbConfig = fromTelemetryConfig(config);
String database = influxDbConfig.database();
String measurement = influxDbConfig.measurement();
BatchPoints batchPoints = BatchPoints.database(database).build();
for (FlowInfo flowInfo : record.flowInfos()) {
Point.Builder pointBuilder = Point.measurement((measurement == null) ? record.measurement() : measurement).tag(FLOW_TYPE, String.valueOf(flowInfo.flowType())).tag(DEVICE_ID, flowInfo.deviceId().toString()).tag(INPUT_INTERFACE_ID, String.valueOf(flowInfo.inputInterfaceId())).tag(OUTPUT_INTERFACE_ID, String.valueOf(flowInfo.outputInterfaceId())).tag(VXLAN_ID, String.valueOf(flowInfo.vxlanId())).tag(SRC_IP, flowInfo.srcIp().toString()).tag(DST_IP, flowInfo.dstIp().toString()).tag(DST_PORT, getTpPort(flowInfo.dstPort())).tag(PROTOCOL, String.valueOf(flowInfo.protocol())).addField(STARTUP_TIME, flowInfo.statsInfo().startupTime()).addField(FST_PKT_ARR_TIME, flowInfo.statsInfo().fstPktArrTime()).addField(LST_PKT_OFFSET, flowInfo.statsInfo().lstPktOffset()).addField(PREV_ACC_BYTES, flowInfo.statsInfo().prevAccBytes()).addField(PREV_ACC_PKTS, flowInfo.statsInfo().prevAccPkts()).addField(CURR_ACC_BYTES, flowInfo.statsInfo().currAccBytes()).addField(CURR_ACC_PKTS, flowInfo.statsInfo().currAccPkts()).addField(ERROR_PKTS, flowInfo.statsInfo().errorPkts()).addField(DROP_PKTS, flowInfo.statsInfo().dropPkts());
if (flowInfo.vlanId() != null) {
pointBuilder.tag(VLAN_ID, flowInfo.vlanId().toString());
}
if (flowInfo.srcPort() != null) {
pointBuilder.tag(SRC_PORT, getTpPort(flowInfo.srcPort()));
}
if (flowInfo.dstPort() != null) {
pointBuilder.tag(DST_PORT, getTpPort(flowInfo.dstPort()));
}
batchPoints.point(pointBuilder.build());
}
v.write(batchPoints);
});
}
Aggregations