mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #45 from sschneid/uptime_status
Display application 'uptime' in API status endpoint
This commit is contained in:
commit
8337d94aa8
1 changed files with 4 additions and 0 deletions
|
|
@ -5,6 +5,8 @@ module Vmpooler
|
||||||
config_file = File.expand_path('vmpooler.yaml')
|
config_file = File.expand_path('vmpooler.yaml')
|
||||||
$config = YAML.load_file(config_file)
|
$config = YAML.load_file(config_file)
|
||||||
|
|
||||||
|
$config[:uptime] = Time.now
|
||||||
|
|
||||||
# Set some defaults
|
# Set some defaults
|
||||||
$config[:redis] ||= Hash.new
|
$config[:redis] ||= Hash.new
|
||||||
$config[:redis]['server'] ||= 'localhost'
|
$config[:redis]['server'] ||= 'localhost'
|
||||||
|
|
@ -201,6 +203,8 @@ module Vmpooler
|
||||||
result['clone_average'] = $redis.hvals('vmpooler__clone__'+Date.today.to_s).map( &:to_f ).reduce( :+ ) / result['clone_total']
|
result['clone_average'] = $redis.hvals('vmpooler__clone__'+Date.today.to_s).map( &:to_f ).reduce( :+ ) / result['clone_total']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
result['uptime'] = Time.now - $config[:uptime]
|
||||||
|
|
||||||
JSON.pretty_generate(Hash[result.sort_by{|k,v| k}])
|
JSON.pretty_generate(Hash[result.sort_by{|k,v| k}])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue