mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Extend dashboard stats
This PR includes the following changes: - everything at the /dashboard/stats/vmpooler/numbers API endpoint has been moved to /status, and stats-vmpooler-numbers.js is now looking to /status for it's metrics - added '.extra'-classed metrics to stats-vmpooler-numbers.js to pull in daily clone totals, average clone time, etc. - dashboard.css includes an @media query to display the extra metrics if the dashboard's max-width exceeds 1500px
This commit is contained in:
parent
351bd07d91
commit
0253008a3f
3 changed files with 148 additions and 30 deletions
|
|
@ -43,31 +43,6 @@ module Vmpooler
|
|||
}
|
||||
end
|
||||
|
||||
get '/dashboard/stats/vmpooler/numbers/?' do
|
||||
result = Hash.new
|
||||
result['pending'] = 0
|
||||
result['cloning'] = 0
|
||||
result['booting'] = 0
|
||||
result['ready'] = 0
|
||||
result['running'] = 0
|
||||
result['completed'] = 0
|
||||
|
||||
$config[:pools].each do |pool|
|
||||
result['pending'] += $redis.scard('vmpooler__pending__' + pool['name'])
|
||||
result['ready'] += $redis.scard('vmpooler__ready__' + pool['name'])
|
||||
result['running'] += $redis.scard('vmpooler__running__' + pool['name'])
|
||||
result['completed'] += $redis.scard('vmpooler__completed__' + pool['name'])
|
||||
end
|
||||
|
||||
result['cloning'] = $redis.get('vmpooler__tasks__clone')
|
||||
result['booting'] = result['pending'].to_i - result['cloning'].to_i
|
||||
result['booting'] = 0 if result['booting'] < 0
|
||||
result['total'] = result['pending'].to_i + result['ready'].to_i + result['running'].to_i + result['completed'].to_i
|
||||
|
||||
content_type :json
|
||||
JSON.pretty_generate(result)
|
||||
end
|
||||
|
||||
get '/dashboard/stats/vmpooler/pool/?' do
|
||||
result = Hash.new
|
||||
|
||||
|
|
@ -178,11 +153,18 @@ module Vmpooler
|
|||
|
||||
result = {}
|
||||
|
||||
result['status'] = 1
|
||||
|
||||
result['pending'] = 0
|
||||
result['cloning'] = 0
|
||||
result['booting'] = 0
|
||||
result['ready'] = 0
|
||||
result['running'] = 0
|
||||
result['completed'] = 0
|
||||
|
||||
result['capacity_current'] = 0
|
||||
result['capacity_total'] = 0
|
||||
|
||||
result['status'] = 1
|
||||
|
||||
$config[:pools].each do |pool|
|
||||
pool['capacity_current'] = $redis.scard('vmpooler__ready__' + pool['name']).to_i
|
||||
|
||||
|
|
@ -193,6 +175,11 @@ module Vmpooler
|
|||
result['empty'] ||= []
|
||||
result['empty'].push(pool['name'])
|
||||
end
|
||||
|
||||
result['pending'] += $redis.scard('vmpooler__pending__' + pool['name'])
|
||||
result['ready'] += $redis.scard('vmpooler__ready__' + pool['name'])
|
||||
result['running'] += $redis.scard('vmpooler__running__' + pool['name'])
|
||||
result['completed'] += $redis.scard('vmpooler__completed__' + pool['name'])
|
||||
end
|
||||
|
||||
if result['empty']
|
||||
|
|
@ -201,12 +188,17 @@ module Vmpooler
|
|||
|
||||
result['capacity_percent'] = (result['capacity_current'].to_f / result['capacity_total'].to_f) * 100.0
|
||||
|
||||
result['cloning'] = $redis.get('vmpooler__tasks__clone')
|
||||
result['booting'] = result['pending'].to_i - result['cloning'].to_i
|
||||
result['booting'] = 0 if result['booting'] < 0
|
||||
result['total'] = result['pending'].to_i + result['ready'].to_i + result['running'].to_i + result['completed'].to_i
|
||||
|
||||
result['clone_total'] = $redis.hlen('vmpooler__clone__' + Date.today.to_s)
|
||||
if result['clone_total'] > 0
|
||||
result['clone_average'] = $redis.hvals('vmpooler__clone__' + Date.today.to_s).map(&:to_f).reduce(:+) / result['clone_total']
|
||||
end
|
||||
|
||||
result['uptime'] = Time.now - $config[:uptime]
|
||||
result['uptime'] = Time.now - $config[:uptime] if $config[:uptime]
|
||||
|
||||
JSON.pretty_generate(Hash[result.sort_by { |k, _v| k }])
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue