DaanHoogland commented on a change in pull request #5588:
URL: https://github.com/apache/cloudstack/pull/5588#discussion_r783083555
##########
File path:
plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java
##########
@@ -417,73 +527,186 @@ public InfrastructureResponse listInfrastructure() {
// CPU and memory capacities
final CapacityDaoImpl.SummedCapacity cpuCapacity =
getCapacity((int) Capacity.CAPACITY_TYPE_CPU, zoneId, null);
final CapacityDaoImpl.SummedCapacity memoryCapacity =
getCapacity((int) Capacity.CAPACITY_TYPE_MEMORY, zoneId, null);
- final Metrics metrics = new Metrics(cpuCapacity, memoryCapacity);
+ final HostMetrics hostMetrics = new HostMetrics(cpuCapacity,
memoryCapacity);
for (final Cluster cluster :
clusterDao.listClustersByDcId(zoneId)) {
if (cluster == null) {
continue;
}
- metrics.incrTotalResources();
+ hostMetrics.incrTotalResources();
if (cluster.getAllocationState() ==
Grouping.AllocationState.Enabled
&& cluster.getManagedState() ==
Managed.ManagedState.Managed) {
- metrics.incrUpResources();
+ hostMetrics.incrUpResources();
}
for (final Host host:
hostDao.findByClusterId(cluster.getId())) {
if (host == null || host.getType() != Host.Type.Routing) {
continue;
}
- updateHostMetrics(metrics,
hostJoinDao.findById(host.getId()));
+ updateHostMetrics(hostMetrics,
hostJoinDao.findById(host.getId()));
}
}
metricsResponse.setHasAnnotation(zoneResponse.hasAnnotation());
metricsResponse.setState(zoneResponse.getAllocationState());
- metricsResponse.setResource(metrics.getUpResources(),
metrics.getTotalResources());
+ metricsResponse.setResource(hostMetrics.getUpResources(),
hostMetrics.getTotalResources());
// CPU
- metricsResponse.setCpuTotal(metrics.getTotalCpu());
- metricsResponse.setCpuAllocated(metrics.getCpuAllocated(),
metrics.getTotalCpu());
- if (metrics.getCpuUsedPercentage() > 0L) {
- metricsResponse.setCpuUsed(metrics.getCpuUsedPercentage(),
metrics.getTotalHosts());
-
metricsResponse.setCpuMaxDeviation(metrics.getMaximumCpuUsage(),
metrics.getCpuUsedPercentage(), metrics.getTotalHosts());
+ metricsResponse.setCpuTotal(hostMetrics.getTotalCpu());
+ metricsResponse.setCpuAllocated(hostMetrics.getCpuAllocated(),
hostMetrics.getTotalCpu());
+ if (hostMetrics.getCpuUsedPercentage() > 0L) {
+ metricsResponse.setCpuUsed(hostMetrics.getCpuUsedPercentage(),
hostMetrics.getTotalHosts());
+
metricsResponse.setCpuMaxDeviation(hostMetrics.getMaximumCpuUsage(),
hostMetrics.getCpuUsedPercentage(), hostMetrics.getTotalHosts());
}
// Memory
- metricsResponse.setMemTotal(metrics.getTotalMemory());
- metricsResponse.setMemAllocated(metrics.getMemoryAllocated(),
metrics.getTotalMemory());
- if (metrics.getMemoryUsed() > 0L) {
- metricsResponse.setMemUsed(metrics.getMemoryUsed(),
metrics.getTotalMemory());
-
metricsResponse.setMemMaxDeviation(metrics.getMaximumMemoryUsage(),
metrics.getMemoryUsed(), metrics.getTotalHosts());
+ metricsResponse.setMemTotal(hostMetrics.getTotalMemory());
+ metricsResponse.setMemAllocated(hostMetrics.getMemoryAllocated(),
hostMetrics.getTotalMemory());
+ if (hostMetrics.getMemoryUsed() > 0L) {
+ metricsResponse.setMemUsed(hostMetrics.getMemoryUsed(),
hostMetrics.getTotalMemory());
+
metricsResponse.setMemMaxDeviation(hostMetrics.getMaximumMemoryUsage(),
hostMetrics.getMemoryUsed(), hostMetrics.getTotalHosts());
}
// CPU thresholds
-
metricsResponse.setCpuUsageThreshold(metrics.getCpuUsedPercentage(),
metrics.getTotalHosts(), cpuThreshold);
-
metricsResponse.setCpuUsageDisableThreshold(metrics.getCpuUsedPercentage(),
metrics.getTotalHosts(), cpuDisableThreshold);
-
metricsResponse.setCpuAllocatedThreshold(metrics.getCpuAllocated(),
metrics.getTotalCpu(), cpuThreshold);
-
metricsResponse.setCpuAllocatedDisableThreshold(metrics.getCpuAllocated(),
metrics.getTotalCpu(), cpuDisableThreshold);
+
metricsResponse.setCpuUsageThreshold(hostMetrics.getCpuUsedPercentage(),
hostMetrics.getTotalHosts(), cpuThreshold);
+
metricsResponse.setCpuUsageDisableThreshold(hostMetrics.getCpuUsedPercentage(),
hostMetrics.getTotalHosts(), cpuDisableThreshold);
+
metricsResponse.setCpuAllocatedThreshold(hostMetrics.getCpuAllocated(),
hostMetrics.getTotalCpu(), cpuThreshold);
+
metricsResponse.setCpuAllocatedDisableThreshold(hostMetrics.getCpuAllocated(),
hostMetrics.getTotalCpu(), cpuDisableThreshold);
// Memory thresholds
- metricsResponse.setMemoryUsageThreshold(metrics.getMemoryUsed(),
metrics.getTotalMemory(), memoryThreshold);
-
metricsResponse.setMemoryUsageDisableThreshold(metrics.getMemoryUsed(),
metrics.getTotalMemory(), memoryDisableThreshold);
-
metricsResponse.setMemoryAllocatedThreshold(metrics.getMemoryAllocated(),
metrics.getTotalMemory(), memoryThreshold);
-
metricsResponse.setMemoryAllocatedDisableThreshold(metrics.getMemoryAllocated(),
metrics.getTotalMemory(), memoryDisableThreshold);
+
metricsResponse.setMemoryUsageThreshold(hostMetrics.getMemoryUsed(),
hostMetrics.getTotalMemory(), memoryThreshold);
+
metricsResponse.setMemoryUsageDisableThreshold(hostMetrics.getMemoryUsed(),
hostMetrics.getTotalMemory(), memoryDisableThreshold);
+
metricsResponse.setMemoryAllocatedThreshold(hostMetrics.getMemoryAllocated(),
hostMetrics.getTotalMemory(), memoryThreshold);
+
metricsResponse.setMemoryAllocatedDisableThreshold(hostMetrics.getMemoryAllocated(),
hostMetrics.getTotalMemory(), memoryDisableThreshold);
Review comment:
extracted and unified with the ones used in listClusterMetrics.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]