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;
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations