riemann-babbler 1.1.9 → 1.2.0

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.
@@ -4,7 +4,7 @@ require 'resolv'
4
4
 
5
5
  require 'riemann/babbler/support/deep_merge'
6
6
  require 'riemann/babbler'
7
- require 'riemann/babbler/support/pinger'
7
+ require 'riemann/babbler/support/responder'
8
8
 
9
9
  class Riemann::Babbler::Starter
10
10
 
@@ -2,20 +2,25 @@ require 'socket'
2
2
  require 'json'
3
3
 
4
4
  class Riemann::Responder
5
- INFO = {
5
+
6
+ def info
7
+ {
6
8
  :version => Riemann::Babbler::VERSION,
7
- :ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}"
8
- }.freeze
9
+ :ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}",
10
+ :uptime => (Time.now.to_i - @started_at)
11
+ }.to_json
12
+ end
9
13
 
10
14
  def initialize( port = 55755 )
11
15
  @port = port
16
+ @started_at = Time.now.to_i
12
17
  end
13
18
 
14
19
  def start
15
20
  @worker_thread = Thread.new {
16
21
  Socket.tcp_server_loop(@port) do |sock, _|
17
22
  begin
18
- sock.puts INFO.to_json
23
+ sock.puts info
19
24
  ensure
20
25
  sock.close
21
26
  end
@@ -29,4 +34,5 @@ class Riemann::Responder
29
34
  @worker_thread = nil
30
35
  end
31
36
  end
37
+
32
38
  end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.1.9'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
data/spec/default.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  #encoding: utf-8
2
2
 
3
3
  require 'riemann/babbler'
4
+ require 'riemann/babbler/version'
4
5
  require 'riemann/babbler/start'
5
6
  require 'configatron'
6
7
 
@@ -57,4 +58,4 @@ describe Riemann::Babbler do
57
58
  dummyplugin.tcp_port_aviable?('www.ya.ru', 80).should eq true
58
59
  end
59
60
 
60
- end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -194,8 +194,8 @@ files:
194
194
  - lib/riemann/babbler/start.rb
195
195
  - lib/riemann/babbler/support/deep_merge.rb
196
196
  - lib/riemann/babbler/support/monkey_patches.rb
197
- - lib/riemann/babbler/support/pinger.rb
198
197
  - lib/riemann/babbler/support/plugin_helpers.rb
198
+ - lib/riemann/babbler/support/responder.rb
199
199
  - lib/riemann/babbler/version.rb
200
200
  - riemann-babbler.gemspec
201
201
  - spec/config.yml