cf_light_api 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cf_light_api/worker.rb +15 -11
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 892f44f1093e2c4dbe2e195463dafbe2a4038ec3
4
- data.tar.gz: 516a3ddd90bc674dd5ccb9dd8ff4fbaefb3ce586
3
+ metadata.gz: 8ddef2bf8068ab560f90c3d7be40f48d716ca764
4
+ data.tar.gz: dc155276e8f19677c3ae0941f2191b0c1ca8edd3
5
5
  SHA512:
6
- metadata.gz: 2b4a1be614230c15fea449956cb6935648ddddbe5add1a750c390cca984531b1e385d4b6581f9fc7d0e36c8a774dc094dbb9a1f3d26a46afd78dc0fb9662b999
7
- data.tar.gz: 40fe1395ff99687ecce09ddc7ee9fdb16a0447889d2af427780d83964b3afbd8582d131bd9f79d4f55c6cd6d6a2e2b6a3075a3b72b6e55c01ab2012d2257b742
6
+ metadata.gz: e88464f8fce42345d6beda2536cf5b9622ac7f554af1c5c7c98ceb5036924d07a26bc0bff2c88afa5bbfee6dca1e3b4a796cb1ba3cf49f742af7a13a3d95a499
7
+ data.tar.gz: 0537fc2e03b21eabfce23eecfa11f0f928e10cd7ad2d1b1d300f55083d159cafbce950cbcd580bf7ac104b92eb643aaa39dd222182116596ce00d64c3d483d2b
@@ -21,17 +21,16 @@ UPDATE_INTERVAL = (ENV['UPDATE_INTERVAL'] || '5m').to_s
21
21
  UPDATE_TIMEOUT = (ENV['UPDATE_TIMEOUT'] || '5m').to_s
22
22
 
23
23
  lock_manager = Redlock::Client.new([ENV['REDIS_URI']])
24
- scheduler = Rufus::Scheduler.new
24
+ scheduler = Rufus::Scheduler.new
25
25
 
26
26
  @logger.info "Parallel maps: '#{PARALLEL_MAPS}'"
27
27
  @logger.info "Update interval: '#{UPDATE_INTERVAL}'"
28
28
  @logger.info "Update timeout: '#{UPDATE_TIMEOUT}'"
29
+ @logger.info "Graphite server: #{ENV['GRAPHITE']}" if ENV['GRAPHITE']
29
30
 
30
31
  scheduler.every UPDATE_INTERVAL, :first_in => '5s', :overlap => false, :timeout => UPDATE_TIMEOUT do
31
32
  cf_client = nil
32
-
33
- graphite = if ENV['GRAPHITE'] then GraphiteAPI.new(graphite: ENV['GRAPHITE']) end
34
- @logger.info "Sending data to graphite server #{ENV['GRAPHITE']}" if graphite
33
+ graphite = GraphiteAPI.new(graphite: ENV['GRAPHITE']) if ENV['GRAPHITE']
35
34
 
36
35
  begin
37
36
  lock_manager.lock("#{ENV['REDIS_KEY_PREFIX']}:lock", 5*60*1000) do |lock|
@@ -70,16 +69,21 @@ def get_client(cf_api=ENV['CF_API'], cf_user=ENV['CF_USER'], cf_password=ENV['CF
70
69
  end
71
70
 
72
71
  def send_data_to_graphite(data, graphite)
73
- org = data[:org]
72
+ org = data[:org]
74
73
  space = data[:space]
75
- name = data[:name].sub ".", "_" # Some apps have dots in the app name
74
+ name = data[:name].sub ".", "_" # Some apps have dots in the app name
76
75
 
77
76
  data[:instances].each_with_index do |instance_data, index|
78
- instance_data[:stats][:usage].each do |key, value|
79
- if key != :time
80
- graphite_key = "cf_apps.#{org}.#{space}.#{name}.#{index}.#{key}"
81
- graphite.metrics graphite_key => value
82
- end
77
+ graphite_base_key = "cf_apps.#{org}.#{space}.#{name}.#{index}"
78
+
79
+ # Quota data
80
+ [:mem_quota, :disk_quota].each do |key|
81
+ graphite.metrics "#{graphite_base_key}.#{key}" => instance_data[:stats][key]
82
+ end
83
+
84
+ # Usage data
85
+ [:mem, :disk, :cpu].each do |key|
86
+ graphite.metrics "#{graphite_base_key}.#{key}" => instance_data[:stats][:usage][key]
83
87
  end
84
88
  end
85
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf_light_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Springer Platform Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cfoundry
@@ -116,9 +116,9 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ./lib/sinatra/cf_light_api.rb
119
120
  - ./lib/cf_light_api/redis.rb
120
121
  - ./lib/cf_light_api/worker.rb
121
- - ./lib/sinatra/cf_light_api.rb
122
122
  - bin/cf_light_api
123
123
  homepage: https://github.com/springerpe/cf-light-api
124
124
  licenses:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.4.6
143
+ rubygems_version: 2.0.14
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: A super lightweight API for reading App and Org data from CloudFoundry, cached