bipbip 0.6.5 → 0.6.6

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: 6383136be35e4594707a538dea208cc740920e40
4
- data.tar.gz: 501f4cfaefba119254433093fe81854d76eb4ad6
3
+ metadata.gz: 8615ee93456416705bad1b09adc7bfb8368b7bd6
4
+ data.tar.gz: b1effdd60eb893891010b2e2deedd2a32a933a92
5
5
  SHA512:
6
- metadata.gz: 647b5b6d9342433cff972803f234a8258bcf0de68cf110a48b2717493b804e92a7bed0166d9816334cf451a495e40363b995c13b3dc85e9c63473da3d3b30169
7
- data.tar.gz: 9bc94e204b204775184ed9a11ca3f6ceeaf14cc0068e6120ab761b7812c6b79335eabf0049bcad08f30d5ca16c89147e638f3e146be5a63dfad58327343f170f
6
+ metadata.gz: 7f023ced080ea09a708f2ff807784d4961449a1ae9f297a38b830d1998ae2fd03877414395a173eea6ba947aea0b58000a8a441721e6c3e9424b495464090e0d
7
+ data.tar.gz: f8322e10204735a71a92e2263570b95cf71eee1c93ec189a3a077437b09449db459ddfe50c89524f71a8a3a1721f51c84499d167e20bfc6f0992a7d18b8e9026
@@ -4,9 +4,10 @@ module Bipbip
4
4
 
5
5
  class Plugin::Monit < Plugin
6
6
 
7
- #See https://bitbucket.org/tildeslash/monit/src/d60968cf7972cc902e5b6e2961d44456e1d9b736/src/monit.h?at=master#cl-135
8
- # https://bitbucket.org/tildeslash/monit/src/d60968cf7972cc902e5b6e2961d44456e1d9b736/src/monit.h?at=master#cl-146
7
+ # See https://bitbucket.org/tildeslash/monit/src/d60968cf7972cc902e5b6e2961d44456e1d9b736/src/monit.h?at=master#monit.h-145
9
8
  STATE_FAILED = '1'
9
+
10
+ # See https://bitbucket.org/tildeslash/monit/src/d60968cf7972cc902e5b6e2961d44456e1d9b736/src/monit.h?at=master#monit.h-135
10
11
  MONITOR_NOT = '0'
11
12
 
12
13
  def metrics_schema
@@ -4,7 +4,14 @@ module Bipbip
4
4
 
5
5
  def metrics_schema
6
6
  [
7
- {:name => 'connections_requested', :type => 'counter', :unit => 'Requests'},
7
+ {:name => 'connections_accepts', :type => 'counter', :unit => 'Connections'},
8
+ {:name => 'connections_handled', :type => 'counter', :unit => 'Connections'},
9
+ {:name => 'connections_dropped', :type => 'counter', :unit => 'Connections'},
10
+ {:name => 'connections_requests', :type => 'counter', :unit => 'Requests'},
11
+ {:name => 'active_total', :type => 'gauge', :unit => 'Connections'},
12
+ {:name => 'active_reading', :type => 'gauge', :unit => 'Connections'},
13
+ {:name => 'active_writing', :type => 'gauge', :unit => 'Connections'},
14
+ {:name => 'active_waiting', :type => 'gauge', :unit => 'Connections'},
8
15
  ]
9
16
  end
10
17
 
@@ -14,10 +21,36 @@ module Bipbip
14
21
 
15
22
  raise "Invalid response from server at #{config['url']}" unless response.code == "200"
16
23
 
17
- nstats = response.body.split(/\r*\n/)
18
- connections_requested = nstats[2].lstrip.split(/\s+/)[2].to_i
24
+ lines = response.body.split(/\r*\n/)
25
+ lines.map { |line| line.strip! }
19
26
 
20
- {:connections_requested => connections_requested}
27
+ data = {}
28
+
29
+ stats_connections = match_or_fail(lines[2], /^(\d+) (\d+) (\d+)$/)
30
+ data[:connections_accepts] = stats_connections[1].to_i
31
+ data[:connections_handled] = stats_connections[2].to_i
32
+ data[:connections_dropped] = data[:connections_accepts] - data[:connections_handled]
33
+ data[:connections_requests] = stats_connections[3].to_i
34
+
35
+ stats_active_total = match_or_fail(lines[0], /^Active connections: (\d+)$/)
36
+ data[:active_total] = stats_active_total[1].to_i
37
+
38
+ stats_active = match_or_fail(lines[3], /^Reading: (\d+) Writing: (\d+) Waiting: (\d+)$/)
39
+ data[:active_reading] = stats_active[1].to_i
40
+ data[:active_writing] = stats_active[2].to_i
41
+ data[:active_waiting] = stats_active[3].to_i
42
+
43
+ data
44
+ end
45
+
46
+ # @param [String] string
47
+ # @param [Regexp] regexp
48
+ def match_or_fail(string, regexp)
49
+ match_data = regexp.match(string)
50
+ if match_data.nil?
51
+ raise "Data `#{string}` doesn't match pattern `#{regexp}`."
52
+ end
53
+ match_data
21
54
  end
22
55
  end
23
56
  end
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.6.5'
2
+ VERSION = '0.6.6'
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.5
4
+ version: 0.6.6
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: 2015-07-20 00:00:00.000000000 Z
13
+ date: 2015-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: copperegg-revealmetrics
@@ -194,6 +194,20 @@ dependencies:
194
194
  - - "~>"
195
195
  - !ruby/object:Gem::Version
196
196
  version: '2.0'
197
+ - !ruby/object:Gem::Dependency
198
+ name: webmock
199
+ requirement: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - "~>"
202
+ - !ruby/object:Gem::Version
203
+ version: '1.21'
204
+ type: :development
205
+ prerelease: false
206
+ version_requirements: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - "~>"
209
+ - !ruby/object:Gem::Version
210
+ version: '1.21'
197
211
  description: Agent to collect data for common server programs and push them to CopperEgg
198
212
  email: hello@cargomedia.ch
199
213
  executables: