bipbip 0.6.13 → 0.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 231d0f1f6c32e1f3933ca384d8d842e8b6fc28af
4
- data.tar.gz: a74f11900b5261ebfc8d0095de966a7e9c46fcba
3
+ metadata.gz: 8b64ddee8beb29b9234b8521ccec9db1195b806c
4
+ data.tar.gz: bc468a45a4bc15d8c13ed8857b7c4b6c8fe35aaa
5
5
  SHA512:
6
- metadata.gz: aed71ce9f324aaeda5f4dffc6329375e11efd4cb828b56cf5c748657b73d8bb46592c40fb91a749ffa3f8540d8079d37c3f50648faea4a0dff5cf42658b2a77e
7
- data.tar.gz: 80df167f868ddd2248061bec95cfa0c5e9cfd864a88d306eab6ca188661f4c7e8293b3bbf8011992635b2eecae15a4f2774fb2ba4ae2d025225ce66a0f881146
6
+ metadata.gz: 32a14eb70ca91df151b0e4508b939693e49130e84f041bec82176cc70d413ab77ba787b8442ebdeb6c7748bad35b6099fe1ade0ce836b18d674c001f2b88c010
7
+ data.tar.gz: fbbe050904eaab0d09b3dceaf633bc563d8842010670e98a423f5af08e47fcee5bf428caa2e68eefafddb52660ff10e339eb9736ce7593beb5646a00ae8c571b
data/lib/bipbip/agent.rb CHANGED
@@ -21,7 +21,7 @@ module Bipbip
21
21
  Bipbip.logger.info 'Startup...'
22
22
  Bipbip.logger.warn 'No storages configured' if @storages.empty?
23
23
 
24
- fail 'No services configured' if @plugins.empty?
24
+ raise 'No services configured' if @plugins.empty?
25
25
 
26
26
  @storages.each do |storage|
27
27
  @plugins.each do |plugin|
data/lib/bipbip/plugin.rb CHANGED
@@ -67,18 +67,18 @@ module Bipbip
67
67
  end
68
68
 
69
69
  def metrics_schema
70
- fail 'Missing method metrics_schema'
70
+ raise 'Missing method metrics_schema'
71
71
  end
72
72
 
73
73
  def monitor
74
- fail 'Missing method monitor'
74
+ raise 'Missing method monitor'
75
75
  end
76
76
 
77
77
  private
78
78
 
79
79
  def run_measurement(time, storages)
80
80
  data = monitor
81
- fail "#{name} #{source_identifier}: Empty data" if data.empty?
81
+ raise "#{name} #{source_identifier}: Empty data" if data.empty?
82
82
  log(Logger::DEBUG, "Data: #{data}")
83
83
  storages.each do |storage|
84
84
  storage.store_sample(self, time, data)
@@ -11,7 +11,7 @@ module Bipbip
11
11
  uri = URI.parse(config['url'])
12
12
  response = Net::HTTP.get_response(uri)
13
13
 
14
- fail "Invalid response from server at #{config['url']}" unless response.code == '200'
14
+ raise "Invalid response from server at #{config['url']}" unless response.code == '200'
15
15
 
16
16
  astats = response.body.split(/\r*\n/)
17
17
 
@@ -55,7 +55,7 @@ module Bipbip
55
55
  message = ['Command execution failed:', command]
56
56
  message.push 'STDOUT:', output_stdout unless output_stdout.empty?
57
57
  message.push 'STDERR:', output_stderr unless output_stderr.empty?
58
- fail message.join("\n")
58
+ raise message.join("\n")
59
59
  end
60
60
 
61
61
  output_stdout
@@ -19,7 +19,7 @@ module Bipbip
19
19
  ENV.replace(env_backup)
20
20
 
21
21
  body = response.split(/\r?\n\r?\n/)[1]
22
- fail "FastCGI response has no body: #{response}" unless body
22
+ raise "FastCGI response has no body: #{response}" unless body
23
23
  stats = JSON.parse(body)
24
24
 
25
25
  { opcode_mem_size: stats['opcode_mem_size'].to_i, user_mem_size: stats['user_mem_size'].to_i }
@@ -21,7 +21,7 @@ module Bipbip
21
21
  ENV.replace(env_backup)
22
22
 
23
23
  body = response.split(/\r?\n\r?\n/)[1]
24
- fail "FastCGI response has no body: #{response}" unless body
24
+ raise "FastCGI response has no body: #{response}" unless body
25
25
  status = JSON.parse(body)
26
26
 
27
27
  status.reject { |k, _v| !metrics_names.include?(k) }
@@ -24,7 +24,7 @@ module Bipbip
24
24
  ENV.replace(env_backup)
25
25
 
26
26
  body = response.split(/\r?\n\r?\n/)[1]
27
- fail "FastCGI response has no body: #{response}" unless body
27
+ raise "FastCGI response has no body: #{response}" unless body
28
28
  stats = JSON.parse(body)
29
29
  @data_previous ||= stats
30
30
 
@@ -55,7 +55,7 @@ module Bipbip
55
55
  end
56
56
 
57
57
  promise.rescue do |error|
58
- fail(error)
58
+ raise(error)
59
59
  end
60
60
 
61
61
  promise.value
@@ -63,7 +63,7 @@ module Bipbip
63
63
  end
64
64
 
65
65
  promise.rescue do |error|
66
- fail(error)
66
+ raise(error)
67
67
  end
68
68
 
69
69
  promise.value
@@ -44,7 +44,7 @@ module Bipbip
44
44
  def notifier
45
45
  if @notifier.nil?
46
46
  file_stat = File.stat(config['path'])
47
- fail "Cannot read file `#{config['path']}`" unless file_stat.readable?
47
+ raise "Cannot read file `#{config['path']}`" unless file_stat.readable?
48
48
  @lines = []
49
49
  @size = file_stat.size
50
50
  @notifier = create_notifier
@@ -77,15 +77,14 @@ module Bipbip
77
77
  # @return [Mongo::Client]
78
78
  def mongodb_client
79
79
  options = {
80
- 'hostname' => 'localhost',
81
- 'port' => 27_017
80
+ socket_timeout: 2
82
81
  }.merge(config)
83
- @mongodb_client ||= Mongo::Client.new([options['hostname'] + ':' + options['port'].to_s], socket_timeout: 2, slave_ok: true)
82
+ options = Hash[options.map { |(k, v)| [k.to_sym, v] }]
83
+ @mongodb_client ||= Mongo::Client.new([options[:hostname] + ':' + options[:port].to_s], options)
84
84
  end
85
85
 
86
86
  # @return [Mongo::DB]
87
87
  def mongodb_database(db_name)
88
- mongodb_client.with(config['username'], config['password']) unless config['password'].nil?
89
88
  mongodb_client.use(db_name)
90
89
  end
91
90
 
@@ -145,8 +144,8 @@ module Bipbip
145
144
  primary = member_list.find { |member| member['stateStr'] == 'PRIMARY' }
146
145
  secondary = member_list.find { |member| member['stateStr'] == 'SECONDARY' && member['self'] == true }
147
146
 
148
- fail "No primary member in replica `#{status['set']}`" if primary.nil?
149
- fail "Cannot find itself as secondary member in replica `#{status['set']}`" if secondary.nil?
147
+ raise "No primary member in replica `#{status['set']}`" if primary.nil?
148
+ raise "Cannot find itself as secondary member in replica `#{status['set']}`" if secondary.nil?
150
149
 
151
150
  (secondary['optime'].seconds - primary['optime'].seconds)
152
151
  end
@@ -9,7 +9,7 @@ module Bipbip
9
9
  def monitor
10
10
  tcp_summary = `ss -s | grep '^TCP:'`
11
11
  tcp_counters = /^TCP:\s+(\d+) \(estab (\d+), closed (\d+), orphaned (\d+), synrecv (\d+), timewait (\d+)\/(\d+)\), ports (\d+)$/.match(tcp_summary)
12
- fail "Cannot match ss-output `#{tcp_summary}`" unless tcp_counters
12
+ raise "Cannot match ss-output `#{tcp_summary}`" unless tcp_counters
13
13
 
14
14
  { connections_total: tcp_counters[1].to_i }
15
15
  end
@@ -17,7 +17,7 @@ module Bipbip
17
17
  uri = URI.parse(config['url'])
18
18
  response = Net::HTTP.get_response(uri)
19
19
 
20
- fail "Invalid response from server at #{config['url']}" unless response.code == '200'
20
+ raise "Invalid response from server at #{config['url']}" unless response.code == '200'
21
21
 
22
22
  lines = response.body.split(/\r*\n/)
23
23
  lines.map(&:strip!)
@@ -46,7 +46,7 @@ module Bipbip
46
46
  def match_or_fail(string, regexp)
47
47
  match_data = regexp.match(string)
48
48
  if match_data.nil?
49
- fail "Data `#{string}` doesn't match pattern `#{regexp}`."
49
+ raise "Data `#{string}` doesn't match pattern `#{regexp}`."
50
50
  end
51
51
  match_data
52
52
  end
@@ -11,7 +11,7 @@ module Bipbip
11
11
  uri = URI.parse(config['url'])
12
12
  response = Net::HTTP.get_response(uri)
13
13
 
14
- fail "Invalid response from server at #{config['url']}" unless response.code == '200'
14
+ raise "Invalid response from server at #{config['url']}" unless response.code == '200'
15
15
 
16
16
  stats = JSON.parse(response.body)
17
17
 
@@ -25,7 +25,7 @@ module Bipbip
25
25
 
26
26
  response = Net::HTTP.get_response(uri)
27
27
  unless response.code == '200'
28
- fail "Invalid response from server at `#{url}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`"
28
+ raise "Invalid response from server at `#{url}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`"
29
29
  end
30
30
 
31
31
  JSON.parse(response.body)
@@ -14,11 +14,11 @@ module Bipbip
14
14
  end
15
15
 
16
16
  def setup_plugin(_plugin)
17
- fail 'Missing method setup_plugin'
17
+ raise 'Missing method setup_plugin'
18
18
  end
19
19
 
20
20
  def store_sample(_plugin, _time, _data)
21
- fail 'Missing method store_sample'
21
+ raise 'Missing method store_sample'
22
22
  end
23
23
 
24
24
  private
@@ -58,7 +58,7 @@ module Bipbip
58
58
  def store_sample(plugin, time, data)
59
59
  response = ::Copperegg::Revealmetrics::MetricSample.save(plugin.metric_group, plugin.source_identifier, time.to_i, data)
60
60
  if response.code != '200'
61
- fail("Cannot store copperegg data `#{data}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`")
61
+ raise("Cannot store copperegg data `#{data}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`")
62
62
  end
63
63
  end
64
64
 
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.6.13'.freeze
2
+ VERSION = '0.6.14'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bipbip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13
4
+ version: 0.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-21 00:00:00.000000000 Z
13
+ date: 2016-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: copperegg-revealmetrics