diff --git a/lib/vmpooler/api/helpers.rb b/lib/vmpooler/api/helpers.rb index 6d0cbe6..0b98143 100644 --- a/lib/vmpooler/api/helpers.rb +++ b/lib/vmpooler/api/helpers.rb @@ -216,7 +216,7 @@ module Vmpooler capacity[:current] = get_total_across_pools_redis_scard(pools, 'vmpooler__ready__', backend) if capacity[:total] > 0 - capacity[:percent] = ((capacity[:current].to_f / capacity[:total].to_f) * 100.0).round(1) + capacity[:percent] = (capacity[:current].fdiv(capacity[:total]) * 100.0).round(1) end capacity diff --git a/lib/vmpooler/providers/vsphere.rb b/lib/vmpooler/providers/vsphere.rb index 256e55a..8526dea 100644 --- a/lib/vmpooler/providers/vsphere.rb +++ b/lib/vmpooler/providers/vsphere.rb @@ -759,7 +759,7 @@ module Vmpooler return nil if cpu_usage.nil? cpu_size = host.summary.hardware.cpuMhz * host.summary.hardware.numCpuCores - (cpu_usage.to_f / cpu_size.to_f) * 100 + cpu_usage.fdiv(cpu_size) * 100 end def memory_utilization_for(host) @@ -767,7 +767,7 @@ module Vmpooler return nil if memory_usage.nil? memory_size = host.summary.hardware.memorySize / 1024 / 1024 - (memory_usage.to_f / memory_size.to_f) * 100 + memory_usage.fdiv(memory_size) * 100 end def get_average_cluster_utilization(hosts)