mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Account for divide-by-zero
This commit is contained in:
parent
d6ade5ebef
commit
e40335a7cf
1 changed files with 3 additions and 1 deletions
|
|
@ -197,7 +197,9 @@ module Vmpooler
|
|||
result['capacity_perecent'] = ( result['capacity_current'].to_f / result['capacity_total'].to_f ) * 100.0
|
||||
|
||||
result['clone_total'] = $redis.hlen('vmpooler__clone__'+Date.today.to_s)
|
||||
result['clone_average'] = $redis.hvals('vmpooler__clone__'+Date.today.to_s).map( &:to_f ).reduce( :+ ) / result['clone_total']
|
||||
if ( result['clone_total'] > 0 )
|
||||
result['clone_average'] = $redis.hvals('vmpooler__clone__'+Date.today.to_s).map( &:to_f ).reduce( :+ ) / result['clone_total']
|
||||
end
|
||||
|
||||
JSON.pretty_generate(Hash[result.sort_by{|k,v| k}])
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue