mirror of https://github.com/apache/cloudstack.git
Ensure Prometheus doesn't return values when the capacity_state is Disabled (#7007)
Co-authored-by: b-navaro <b.navaro@ca.leaseweb.com>
This commit is contained in:
parent
ca7e1ac1ab
commit
ffccfc6172
|
|
@ -43,6 +43,7 @@ import com.cloud.api.query.vo.StoragePoolJoinVO;
|
|||
import com.cloud.capacity.Capacity;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.CapacityState;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.capacity.dao.CapacityDaoImpl;
|
||||
import com.cloud.configuration.Resource;
|
||||
|
|
@ -156,7 +157,7 @@ public class PrometheusExporterImpl extends ManagerBase implements PrometheusExp
|
|||
|
||||
final String cpuFactor = String.valueOf(CapacityManager.CpuOverprovisioningFactor.valueIn(host.getClusterId()));
|
||||
final CapacityVO cpuCapacity = capacityDao.findByHostIdType(host.getId(), Capacity.CAPACITY_TYPE_CPU);
|
||||
if (cpuCapacity != null) {
|
||||
if (cpuCapacity != null && cpuCapacity.getCapacityState() == CapacityState.Enabled) {
|
||||
metricsList.add(new ItemHostCpu(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, USED, cpuCapacity.getUsedCapacity(), isDedicated, hostTags));
|
||||
metricsList.add(new ItemHostCpu(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), cpuFactor, TOTAL, cpuCapacity.getTotalCapacity(), isDedicated, hostTags));
|
||||
} else {
|
||||
|
|
@ -166,7 +167,7 @@ public class PrometheusExporterImpl extends ManagerBase implements PrometheusExp
|
|||
|
||||
final String memoryFactor = String.valueOf(CapacityManager.MemOverprovisioningFactor.valueIn(host.getClusterId()));
|
||||
final CapacityVO memCapacity = capacityDao.findByHostIdType(host.getId(), Capacity.CAPACITY_TYPE_MEMORY);
|
||||
if (memCapacity != null) {
|
||||
if (memCapacity != null && memCapacity.getCapacityState() == CapacityState.Enabled) {
|
||||
metricsList.add(new ItemHostMemory(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, USED, memCapacity.getUsedCapacity(), isDedicated, hostTags));
|
||||
metricsList.add(new ItemHostMemory(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), memoryFactor, TOTAL, memCapacity.getTotalCapacity(), isDedicated, hostTags));
|
||||
} else {
|
||||
|
|
@ -177,7 +178,7 @@ public class PrometheusExporterImpl extends ManagerBase implements PrometheusExp
|
|||
metricsList.add(new ItemHostVM(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), vmDao.listByHostId(host.getId()).size()));
|
||||
|
||||
final CapacityVO coreCapacity = capacityDao.findByHostIdType(host.getId(), Capacity.CAPACITY_TYPE_CPU_CORE);
|
||||
if (coreCapacity != null) {
|
||||
if (coreCapacity != null && coreCapacity.getCapacityState() == CapacityState.Enabled) {
|
||||
metricsList.add(new ItemVMCore(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), USED, coreCapacity.getUsedCapacity(), isDedicated, hostTags));
|
||||
metricsList.add(new ItemVMCore(zoneName, zoneUuid, host.getName(), host.getUuid(), host.getPrivateIpAddress(), TOTAL, coreCapacity.getTotalCapacity(), isDedicated, hostTags));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue