mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Provide more numbers to the dashboard
This commit is contained in:
parent
f4caa5a3ad
commit
4be2c0ef3e
2 changed files with 107 additions and 20 deletions
|
|
@ -29,6 +29,42 @@ d3.json( numbers_url,
|
|||
|
||||
$( '#stats-vcloud-numbers' ).empty();
|
||||
|
||||
stats_vcloud_numbers__svg[ 'total' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10px 25px 0px 0px' )
|
||||
.style( 'padding', '0px 0px 20px 0px' )
|
||||
.attr( 'width', numbers_width + 'px' )
|
||||
.attr( 'height', numbers_height + 'px' );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'total' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'total VMs' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': numbers_height,
|
||||
'font-face': '\'PT Sans\', sans-serif',
|
||||
'font-size': '12px',
|
||||
'font-weight': 'bold',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'total' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'total' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
'y': '36',
|
||||
'font-face': '\'PT Sans\', sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '50px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#444'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'ready' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10px 25px 0px 0px' )
|
||||
|
|
@ -65,17 +101,17 @@ d3.json( numbers_url,
|
|||
'fill': '#444'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'pending' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
stats_vcloud_numbers__svg[ 'cloning' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10px 25px 0px 0px' )
|
||||
.style( 'padding', '0px 0px 20px 0px' )
|
||||
.attr( 'width', numbers_width + 'px' )
|
||||
.attr( 'height', numbers_height + 'px' );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'pending' ]
|
||||
stats_vcloud_numbers__svg[ 'cloning' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'being built' )
|
||||
( 'being cloned' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
|
|
@ -86,10 +122,10 @@ d3.json( numbers_url,
|
|||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'pending' ]
|
||||
stats_vcloud_numbers__svg[ 'cloning' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'pending' ] )
|
||||
( stats_vcloud_numbers__data__live[ 'cloning' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
|
|
@ -101,6 +137,48 @@ d3.json( numbers_url,
|
|||
'fill': '#444'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'booting' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10px 25px 0px 0px' )
|
||||
.style( 'padding', '0px 0px 20px 0px' )
|
||||
.attr( 'width', numbers_width + 'px' )
|
||||
.attr( 'height', numbers_height + 'px' );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'booting' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( 'booting up' )
|
||||
)
|
||||
.attr( {
|
||||
'x': '5',
|
||||
'y': numbers_height,
|
||||
'font-face': '\'PT Sans\', sans-serif',
|
||||
'font-size': '12px',
|
||||
'font-weight': 'bold',
|
||||
'fill': '#888'
|
||||
} );
|
||||
|
||||
stats_vcloud_numbers__svg[ 'booting' ]
|
||||
.append( 'text' )
|
||||
.text(
|
||||
( stats_vcloud_numbers__data__live[ 'booting' ] )
|
||||
)
|
||||
.attr( {
|
||||
'x': '0',
|
||||
'y': '36',
|
||||
'font-face': '\'PT Sans\', sans-serif',
|
||||
'font-weight': 'bold',
|
||||
'font-size': '50px',
|
||||
'letter-spacing': '-0.05em',
|
||||
'fill': '#444'
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
stats_vcloud_numbers__svg[ 'running' ] = d3.select( '#stats-vcloud-numbers' )
|
||||
.append( 'svg' )
|
||||
.style( 'margin', '10px 25px 0px 0px' )
|
||||
|
|
|
|||
|
|
@ -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