Skip to content

Commit

Permalink
Merge pull request #4 from alekseimakarevich/master
Browse files Browse the repository at this point in the history
Added monitoring for mem usage
  • Loading branch information
mgarciap committed Mar 17, 2016
2 parents fa05f06 + e1229ef commit fcc8005
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
source 'https://s3.amazonaws.com/bosh-jenkins-gems/'

ruby '2.1.5'
#ruby '2.1.5'

gem 'cfoundry', '4.7.2.rc1'
20 changes: 20 additions & 0 deletions bin/auto_scale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
puts "-"*30
puts

threshold = 70
puts "Memory threshold: #{threshold}%"
puts "-"*30
puts

while true do
avg_cpu_load = app_average_cpu_load app
Expand All @@ -40,6 +44,22 @@
puts "------------> AVG CPU Load went over threshold (#{threshold} %), scaling app by 1 instance"
scale_app(app, 1)
end
if avg_mem >= threshold
puts "------------> AVG MEM Load went over threshold (#{threshold} %), scaling app by 1 instance"
scale_app(app, 1)
end
app.stats.each do |i, app_stat|
if app_stat.keys.include? :stats
i_used = app_stat[:stats][:usage][:mem]
i_quota = app_stat[:stats][:mem_quota]
i_perc = i_used * 100 / i_quota
#puts "Instance #{i} use: #{humanise_bytes_to_megabytes i_use}"
#puts "Instance #{i} quota: #{humanise_bytes_to_megabytes i_quota}"
puts "#{config.application} - #{i} use: #{i_perc}%"
else
puts "Instance #{i} still booting..."
end
end

sleep 2.0
end

0 comments on commit fcc8005

Please sign in to comment.