cf_light_api 2.2.1.pre1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cf_light_api/worker.rb +9 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d48a0a566e7cbb841e1b577f71058c3d4b1a25ef
|
4
|
+
data.tar.gz: 9362b13d934a01239131c2ef93e63f2b9ec84111
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 786bc3faae369178e518d5762455c9f0eaa372fcd78ef448638cce2e2b54f906dce9ddc9ad6ed5820c27791816c82e922e9d0e7e8ed363acb86d83d3e5048371
|
7
|
+
data.tar.gz: 809390e230760ed3a8c3264a36c2d1ddc600fb365ff6c5879c936be139a53e8170633fd6ab70f79a147469c098b0449c410039a0547567553560cf318f6e0de5
|
data/lib/cf_light_api/worker.rb
CHANGED
@@ -26,9 +26,10 @@ class CFLightAPIWorker
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
# If either of the Graphite settings are set, verify that they are both set, or exit with an error.
|
29
|
+
# If either of the Graphite settings are set, verify that they are both set, or exit with an error. CF_ENV_NAME is used
|
30
|
+
# to prefix the Graphite key, to allow filtering by environment if you run more than one.
|
30
31
|
if ENV['GRAPHITE_HOST'] or ENV['GRAPHITE_PORT']
|
31
|
-
['GRAPHITE_HOST', 'GRAPHITE_PORT'].each do |env|
|
32
|
+
['GRAPHITE_HOST', 'GRAPHITE_PORT', 'CF_ENV_NAME'].each do |env|
|
32
33
|
unless ENV[env]
|
33
34
|
@logger.info "Error: please set the '#{env}' environment variable to enable exporting to Graphite."
|
34
35
|
exit 1
|
@@ -46,7 +47,7 @@ class CFLightAPIWorker
|
|
46
47
|
@logger.info "Update timeout: '#{@update_timeout}'"
|
47
48
|
|
48
49
|
if ENV['GRAPHITE_HOST'] and ENV['GRAPHITE_PORT']
|
49
|
-
@logger.info "Graphite server: #{ENV['GRAPHITE_HOST']}:#{ENV['GRAPHITE_PORT']}"
|
50
|
+
@logger.info "Graphite server: #{ENV['GRAPHITE_HOST']}:#{ENV['GRAPHITE_PORT']}"
|
50
51
|
else
|
51
52
|
@logger.info 'Graphite server: Disabled'
|
52
53
|
end
|
@@ -68,9 +69,9 @@ class CFLightAPIWorker
|
|
68
69
|
|
69
70
|
resources = []
|
70
71
|
response = JSON.parse(@cf_client.base.rest_client.request(method, path)[1][:body])
|
71
|
-
|
72
|
+
|
72
73
|
# Some endpoints return a 'resources' array, others are flat, depending on the path.
|
73
|
-
if response['resources']
|
74
|
+
if response['resources']
|
74
75
|
resources << response['resources']
|
75
76
|
else
|
76
77
|
resources << response
|
@@ -92,7 +93,7 @@ class CFLightAPIWorker
|
|
92
93
|
sanitised_app_name = app_name.gsub ".", "_" # Some apps have dots in the app name which breaks the Graphite key path
|
93
94
|
|
94
95
|
instance_stats.each_with_index do |instance_data, index|
|
95
|
-
graphite_base_key = "cf_apps.#{org}.#{space}.#{sanitised_app_name}.#{index}"
|
96
|
+
graphite_base_key = "cf_apps.#{ENV['CF_ENV_NAME']}.#{org}.#{space}.#{sanitised_app_name}.#{index}"
|
96
97
|
@logger.info " Exporting app instance \##{index} usage statistics to Graphite, path '#{graphite_base_key}'"
|
97
98
|
|
98
99
|
# Quota data
|
@@ -133,7 +134,7 @@ class CFLightAPIWorker
|
|
133
134
|
|
134
135
|
def update_cf_data
|
135
136
|
@cf_client = nil
|
136
|
-
@graphite = GraphiteAPI.new(graphite: "#{ENV['GRAPHITE_HOST']}:#{ENV['GRAPHITE_PORT']}") if ENV['GRAPHITE_HOST'] and ENV['GRAPHITE_PORT']
|
137
|
+
@graphite = GraphiteAPI.new(graphite: "#{ENV['GRAPHITE_HOST']}:#{ENV['GRAPHITE_PORT']}") if ENV['GRAPHITE_HOST'] and ENV['GRAPHITE_PORT'] and ENV['CF_ENV_NAME']
|
137
138
|
|
138
139
|
begin
|
139
140
|
@lock_manager.lock("#{ENV['REDIS_KEY_PREFIX']}:lock", 5*60*1000) do |lock|
|
@@ -200,7 +201,7 @@ class CFLightAPIWorker
|
|
200
201
|
instance_stats = formatted_instance_stats_for_app(app)
|
201
202
|
running_instances = instance_stats.select{|instance| instance['stats']['uris'] if instance['state'] == 'RUNNING'}
|
202
203
|
raise "There are no running instances of this app." if running_instances.empty?
|
203
|
-
|
204
|
+
|
204
205
|
if @graphite
|
205
206
|
send_instance_usage_data_to_graphite(instance_stats, org['entity']['name'], space['entity']['name'], app['entity']['name'])
|
206
207
|
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: 2.
|
4
|
+
version: 2.3.0
|
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:
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cfoundry
|
@@ -135,9 +135,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- - '
|
138
|
+
- - '>='
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
140
|
+
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
143
|
rubygems_version: 2.0.14
|