Search in sources :

Example 1 with TopologyMetricsService

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());
    }
}
Also used : TopologyMetricsService(org.onosproject.metrics.topology.TopologyMetricsService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MetricsModule(com.codahale.metrics.json.MetricsModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with TopologyMetricsService

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("");
        }
    }
}
Also used : TopologyMetricsService(org.onosproject.metrics.topology.TopologyMetricsService) TopologyEvent(org.onosproject.net.topology.TopologyEvent) TopologyEvent(org.onosproject.net.topology.TopologyEvent) Event(org.onosproject.event.Event)

Aggregations

TopologyMetricsService (org.onosproject.metrics.topology.TopologyMetricsService)2 MetricsModule (com.codahale.metrics.json.MetricsModule)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Event (org.onosproject.event.Event)1 TopologyEvent (org.onosproject.net.topology.TopologyEvent)1