mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Provide more numbers to the dashboard
This commit is contained in:
parent
175dbca9ca
commit
3a4146a0ed
2 changed files with 107 additions and 20 deletions
|
|
@ -34,6 +34,8 @@ end
|
|||
get '/dashboard/stats/vcloud/numbers' do
|
||||
result = Hash.new
|
||||
result['pending'] = 0
|
||||
result['cloning'] = 0
|
||||
result['booting'] = 0
|
||||
result['ready'] = 0
|
||||
result['running'] = 0
|
||||
result['completed'] = 0
|
||||
|
|
@ -45,6 +47,10 @@ get '/dashboard/stats/vcloud/numbers' do
|
|||
result['completed'] += $redis.scard( 'vmware_host_pool__completed__' + pool['name'] )
|
||||
end
|
||||
|
||||
result['cloning'] = $redis.get( 'vmware_host_pool__tasks__clone' )
|
||||
result['booting'] = result['pending'].to_i - result['cloning'].to_i
|
||||
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
|
||||
|
|
@ -62,29 +68,32 @@ get '/dashboard/stats/vcloud/pool' do
|
|||
if ( config[:config]['graphite'] )
|
||||
history ||= Hash.new
|
||||
|
||||
buffer = open( 'http://'+config[:config]['graphite']+'/render?target=vcloud.ready.*&from=-1hour&format=json' ).read
|
||||
history = JSON.parse( buffer )
|
||||
begin
|
||||
buffer = open( 'http://'+config[:config]['graphite']+'/render?target=vcloud.ready.*&from=-1hour&format=json' ).read
|
||||
history = JSON.parse( buffer )
|
||||
|
||||
history.each do |pool|
|
||||
if pool['target'] =~ /.*\.(.*)$/
|
||||
pool['name'] = $1
|
||||
history.each do |pool|
|
||||
if pool['target'] =~ /.*\.(.*)$/
|
||||
pool['name'] = $1
|
||||
|
||||
if ( result[pool['name']] )
|
||||
pool['last'] = result[pool['name']]['size']
|
||||
result[pool['name']]['history'] ||= Array.new
|
||||
if ( result[pool['name']] )
|
||||
pool['last'] = result[pool['name']]['size']
|
||||
result[pool['name']]['history'] ||= Array.new
|
||||
|
||||
pool['datapoints'].each do |metric|
|
||||
8.times do |n|
|
||||
if ( metric[0] )
|
||||
pool['last'] = metric[0].to_i
|
||||
result[pool['name']]['history'].push( metric[0].to_i )
|
||||
else
|
||||
result[pool['name']]['history'].push( pool['last'] )
|
||||
pool['datapoints'].each do |metric|
|
||||
8.times do |n|
|
||||
if ( metric[0] )
|
||||
pool['last'] = metric[0].to_i
|
||||
result[pool['name']]['history'].push( metric[0].to_i )
|
||||
else
|
||||
result[pool['name']]['history'].push( pool['last'] )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
else
|
||||
config[:pools].each do |pool|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue