use of org.onosproject.metrics.topology.TopologyMetricsService in project onos by opennetworkinglab.
the class TopologyEventsMetricsCommand method doExecute.
@Override
protected void doExecute() {
TopologyMetricsService service = get(TopologyMetricsService.class);
if (outputJson()) {
ObjectMapper mapper = new ObjectMapper().registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false));
ObjectNode result = mapper.createObjectNode();
result = json(mapper, result, "topologyDeviceEvent", service.topologyDeviceEventMetric());
result = json(mapper, result, "topologyHostEvent", service.topologyHostEventMetric());
result = json(mapper, result, "topologyLinkEvent", service.topologyLinkEventMetric());
result = json(mapper, result, "topologyGraphEvent", service.topologyGraphEventMetric());
result = json(mapper, result, "topologyGraphReasonsEvent", service.topologyGraphReasonsEventMetric());
print("%s", result);
} else {
printEventMetric("Device", service.topologyDeviceEventMetric());
printEventMetric("Host", service.topologyHostEventMetric());
printEventMetric("Link", service.topologyLinkEventMetric());
printEventMetric("Graph", service.topologyGraphEventMetric());
printEventMetric("Graph Reasons", service.topologyGraphReasonsEventMetric());
}
}
use of org.onosproject.metrics.topology.TopologyMetricsService in project onos by opennetworkinglab.
the class TopologyEventsListCommand method doExecute.
@Override
protected void doExecute() {
TopologyMetricsService service = get(TopologyMetricsService.class);
if (outputJson()) {
print("%s", json(service.getEvents()));
} else {
for (Event event : service.getEvents()) {
print(FORMAT_EVENT, event);
if (event instanceof TopologyEvent) {
TopologyEvent topologyEvent = (TopologyEvent) event;
for (Event reason : topologyEvent.reasons()) {
print(FORMAT_REASON, reason);
}
}
// Extra empty line for clarity
print("");
}
}
}
Aggregations