Search in sources :

Example 1 with ControlPlaneMonitorService

use of org.onosproject.cpman.ControlPlaneMonitorService in project onos by opennetworkinglab.

the class ControlMetricsStatsListCommand method doExecute.

@Override
protected void doExecute() {
    ControlPlaneMonitorService service = get(ControlPlaneMonitorService.class);
    NodeId nodeId = NodeId.nodeId(node);
    switch(type) {
        case "cpu":
            printMetricsStats(service, nodeId, CPU_METRICS);
            break;
        case "memory":
            printMetricsStats(service, nodeId, MEMORY_METRICS);
            break;
        case "disk":
            printMetricsStats(service, nodeId, DISK_METRICS, name);
            break;
        case "network":
            printMetricsStats(service, nodeId, NETWORK_METRICS, name);
            break;
        case "control_message":
            if (name != null) {
                printMetricsStats(service, nodeId, CONTROL_MESSAGE_METRICS, DeviceId.deviceId(name));
            }
            break;
        default:
            print(INVALID_TYPE);
            break;
    }
}
Also used : ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId)

Example 2 with ControlPlaneMonitorService

use of org.onosproject.cpman.ControlPlaneMonitorService in project onos by opennetworkinglab.

the class ControlMetricsWebResource method cpuMetrics.

/**
 * Returns cpu metrics.
 *
 * @return cpu metrics
 * @onos.rsModel CpuMetrics
 */
@GET
@Path("cpu_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response cpuMetrics() {
    ObjectNode root = mapper().createObjectNode();
    ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
    ClusterService clusterService = get(ClusterService.class);
    NodeId localNodeId = clusterService.getLocalNode().id();
    metricsStats(monitorService, localNodeId, CPU_METRICS, root);
    return ok(root).build();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with ControlPlaneMonitorService

use of org.onosproject.cpman.ControlPlaneMonitorService in project onos by opennetworkinglab.

the class ControlMetricsWebResource method diskMetrics.

/**
 * Returns disk metrics of all resources.
 *
 * @return disk metrics of all resources
 * @onos.rsModel DiskMetrics
 */
@GET
@Path("disk_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response diskMetrics() {
    ObjectNode root = mapper().createObjectNode();
    ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
    ClusterService clusterService = get(ClusterService.class);
    NodeId localNodeId = clusterService.getLocalNode().id();
    ArrayNode diskNodes = root.putArray("disks");
    monitorService.availableResourcesSync(localNodeId, DISK).forEach(name -> {
        ObjectNode diskNode = mapper().createObjectNode();
        ObjectNode valueNode = mapper().createObjectNode();
        metricsStats(monitorService, localNodeId, DISK_METRICS, name, valueNode);
        diskNode.put("name", name);
        diskNode.set("value", valueNode);
        diskNodes.add(diskNode);
    });
    return ok(root).build();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with ControlPlaneMonitorService

use of org.onosproject.cpman.ControlPlaneMonitorService in project onos by opennetworkinglab.

the class ControlMetricsWebResource method networkMetrics.

/**
 * Returns network metrics of all resources.
 *
 * @return network metrics of all resources
 * @onos.rsModel NetworkMetrics
 */
@GET
@Path("network_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response networkMetrics() {
    ObjectNode root = mapper().createObjectNode();
    ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
    ClusterService clusterService = get(ClusterService.class);
    NodeId localNodeId = clusterService.getLocalNode().id();
    ArrayNode networkNodes = root.putArray("networks");
    monitorService.availableResourcesSync(localNodeId, NETWORK).forEach(name -> {
        ObjectNode networkNode = mapper().createObjectNode();
        ObjectNode valueNode = mapper().createObjectNode();
        metricsStats(monitorService, localNodeId, NETWORK_METRICS, name, valueNode);
        networkNode.put("name", name);
        networkNode.set("value", valueNode);
        networkNodes.add(networkNode);
    });
    return ok(root).build();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with ControlPlaneMonitorService

use of org.onosproject.cpman.ControlPlaneMonitorService in project onos by opennetworkinglab.

the class ControlMetricsWebResource method memoryMetrics.

/**
 * Returns memory metrics.
 *
 * @return memory metrics
 * @onos.rsModel MemoryMetrics
 */
@GET
@Path("memory_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response memoryMetrics() {
    ObjectNode root = mapper().createObjectNode();
    ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
    ClusterService clusterService = get(ClusterService.class);
    NodeId localNodeId = clusterService.getLocalNode().id();
    metricsStats(monitorService, localNodeId, MEMORY_METRICS, root);
    return ok(root).build();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ControlPlaneMonitorService (org.onosproject.cpman.ControlPlaneMonitorService)14 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)11 Path (javax.ws.rs.Path)11 NodeId (org.onosproject.cluster.NodeId)9 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 ClusterService (org.onosproject.cluster.ClusterService)7 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)6 IOException (java.io.IOException)4 Consumes (javax.ws.rs.Consumes)4 POST (javax.ws.rs.POST)4 MetricsService (org.onlab.metrics.MetricsService)4 ControlMetric (org.onosproject.cpman.ControlMetric)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Optional (java.util.Optional)2 Set (java.util.Set)2 ControlLoadSnapshot (org.onosproject.cpman.ControlLoadSnapshot)2 ControlMetricType (org.onosproject.cpman.ControlMetricType)2 CONTROL_MESSAGE_METRICS (org.onosproject.cpman.ControlResource.CONTROL_MESSAGE_METRICS)2 CPU_METRICS (org.onosproject.cpman.ControlResource.CPU_METRICS)2