systeminstances field (#7871)

Co-authored-by: Henrique Sato <henrique.sato@scclouds.com.br>
This commit is contained in:
sato03 2023-08-20 10:41:07 -03:00 committed by GitHub
parent 1065e9046b
commit 9083a677ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -682,8 +682,10 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements
final Float cpuDisableThreshold = DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.valueIn(clusterId);
final Float memoryDisableThreshold = DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.valueIn(clusterId);
Long upInstances = 0L;
Long totalInstances = 0L;
long upInstances = 0L;
long totalInstances = 0L;
long upSystemInstances = 0L;
long totalSystemInstances = 0L;
for (final VMInstanceVO instance: vmInstanceDao.listByHostId(hostId)) {
if (instance == null) {
continue;
@ -693,10 +695,16 @@ public class MetricsServiceImpl extends MutualExclusiveIdsManagerBase implements
if (instance.getState() == VirtualMachine.State.Running) {
upInstances++;
}
} else if (instance.getType().isUsedBySystem()) {
totalSystemInstances++;
if (instance.getState() == VirtualMachine.State.Running) {
upSystemInstances++;
}
}
}
metricsResponse.setPowerState(hostResponse.getOutOfBandManagementResponse().getPowerState());
metricsResponse.setInstances(upInstances, totalInstances);
metricsResponse.setSystemInstances(upSystemInstances, totalSystemInstances);
metricsResponse.setCpuTotal(hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
metricsResponse.setCpuUsed(hostResponse.getCpuUsed(), hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
metricsResponse.setCpuAllocated(hostResponse.getCpuAllocated(), hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());

View File

@ -36,6 +36,10 @@ public class HostMetricsResponse extends HostResponse {
@Param(description = "instances on the host")
private String instances;
@SerializedName("systeminstances")
@Param(description = "system vm instances on the host")
private String systemInstances;
@SerializedName("cputotalghz")
@Param(description = "the total cpu capacity in Ghz")
private String cpuTotal;
@ -108,10 +112,12 @@ public class HostMetricsResponse extends HostResponse {
this.powerState = powerState;
}
public void setInstances(final Long running, final Long total) {
if (running != null && total != null) {
this.instances = String.format("%d / %d", running, total);
}
public void setSystemInstances(final long running, final long total) {
this.systemInstances = String.format("%d / %d", running, total);
}
public void setInstances(final long running, final long total) {
this.instances = String.format("%d / %d", running, total);
}
public void setCpuTotal(final Integer cpuNumber, final Long cpuSpeed) {