mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
B OpenNebula/one#5113: Correct monitor CPU values in vCenter (#378)
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io> (cherry picked from commit f148c3fa65a0f45a24fc68c7f6cfe36c687ad3e6)
This commit is contained in:
parent
89e36f7b24
commit
2233d0da5b
@ -309,30 +309,17 @@ class Cluster
|
||||
def cluster_monitoring
|
||||
resource_usage_summary = @cluster.item.GetResourceUsage()
|
||||
|
||||
metrics = @cluster.item.collect(*(CLUSTER_PROPERTIES[1]))
|
||||
num_cpu_cores = metrics[0].to_f
|
||||
total_cpu = resource_usage_summary.cpuCapacityMHz.to_i
|
||||
used_cpu = resource_usage_summary.cpuUsedMHz.to_i
|
||||
total_memory = resource_usage_summary.memCapacityMB.to_i
|
||||
used_mem = resource_usage_summary.memUsedMB.to_i
|
||||
|
||||
total_cpu = resource_usage_summary.cpuCapacityMHz.to_f
|
||||
effective_cpu = resource_usage_summary.cpuUsedMHz.to_f
|
||||
total_memory = resource_usage_summary.memCapacityMB.to_i
|
||||
effective_mem = resource_usage_summary.memUsedMB.to_i
|
||||
|
||||
if num_cpu_cores > 0
|
||||
mhz_core = total_cpu / num_cpu_cores
|
||||
eff_core = effective_cpu / mhz_core
|
||||
else
|
||||
eff_core = 0
|
||||
end
|
||||
|
||||
free_cpu = (eff_core * 100).to_i
|
||||
used_cpu = (total_cpu - free_cpu).to_i
|
||||
|
||||
total_mem = total_memory / 1024
|
||||
free_mem = effective_mem * 1024
|
||||
free_cpu = total_cpu - used_cpu
|
||||
free_mem = total_memory - used_mem
|
||||
|
||||
unindent(<<-EOS)
|
||||
HYPERVISOR = vcenter
|
||||
USEDMEMORY = "#{(total_mem - free_mem)}"
|
||||
USEDMEMORY = "#{(used_mem * 1024)}"
|
||||
FREEMEMORY = "#{free_mem}"
|
||||
USEDCPU = "#{used_cpu}"
|
||||
FREECPU = "#{free_cpu}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user