riemann-client 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,7 +62,7 @@ module Riemann
62
62
  @locket.synchronize do
63
63
  begin
64
64
  tries += 1
65
- yield (@socket || connect)
65
+ yield(@socket || connect)
66
66
  rescue IOError => e
67
67
  raise if tries > 3
68
68
  connect and retry
@@ -54,7 +54,7 @@ module Riemann
54
54
  @locket.synchronize do
55
55
  begin
56
56
  tries += 1
57
- yield (@socket || connect)
57
+ yield(@socket || connect)
58
58
  rescue IOError => e
59
59
  raise if tries > 3
60
60
  connect and retry
@@ -6,7 +6,7 @@ class Riemann::Client
6
6
  class ServerError < Error; end
7
7
  class Unsupported < Error; end
8
8
  class TooBig < Unsupported; end
9
-
9
+
10
10
  require 'thread'
11
11
  require 'socket'
12
12
  require 'time'
@@ -72,7 +72,7 @@ class Riemann::Client
72
72
 
73
73
  # Ask for states
74
74
  def query(string = "true")
75
- send_recv Riemann::Message.new(query: Riemann::Query.new(string: string))
75
+ send_recv Riemann::Message.new(:query => Riemann::Query.new(:string => string))
76
76
  end
77
77
 
78
78
  def send_recv(*a)
data/lib/riemann/event.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Riemann
2
2
  class Event
3
3
  include Beefcake::Message
4
-
5
- optional :time, :int64, 1
4
+
5
+ optional :time, :int64, 1
6
6
  optional :state, :string, 2
7
7
  optional :service, :string, 3
8
8
  optional :host, :string, 4
@@ -21,7 +21,7 @@ module Riemann
21
21
  else
22
22
  Event.new init
23
23
  end
24
-
24
+
25
25
  # Metric
26
26
  init.metric_f ||= states.inject(0.0) { |a, state|
27
27
  a + (state.metric || 0)
@@ -35,10 +35,10 @@ module Riemann
35
35
  init.service ||= mode states.map(&:service)
36
36
 
37
37
  # Time
38
- init.time = begin
38
+ init.time = begin
39
39
  times = states.map(&:time).compact
40
40
  (times.inject(:+) / times.size).to_i
41
- rescue
41
+ rescue
42
42
  end
43
43
  init.time ||= Time.now.to_i
44
44
 
@@ -55,7 +55,7 @@ module Riemann
55
55
  else
56
56
  Event.new init
57
57
  end
58
-
58
+
59
59
  # Metric
60
60
  init.metric_f ||= states.inject(0.0) { |a, state|
61
61
  a + (state.metric || 0)
@@ -69,16 +69,16 @@ module Riemann
69
69
  init.service ||= mode states.map(&:service)
70
70
 
71
71
  # Time
72
- init.time = begin
72
+ init.time = begin
73
73
  times = states.map(&:time).compact
74
74
  (times.inject(:+) / times.size).to_i
75
- rescue
75
+ rescue
76
76
  end
77
77
  init.time ||= Time.now.to_i
78
78
 
79
79
  init
80
80
  end
81
-
81
+
82
82
  # Finds the maximum of a set of states. Metric is the maximum. Event is the
83
83
  # highest, as defined by Dash.config.state_order. Time is the mean.
84
84
  def self.max(states, init = Event.new)
@@ -88,7 +88,7 @@ module Riemann
88
88
  else
89
89
  Event.new init
90
90
  end
91
-
91
+
92
92
  # Metric
93
93
  init.metric_f ||= states.inject(0.0) { |a, state|
94
94
  a + (state.metric || 0)
@@ -103,16 +103,16 @@ module Riemann
103
103
  end
104
104
 
105
105
  # Time
106
- init.time = begin
106
+ init.time = begin
107
107
  times = states.map(&:time).compact
108
108
  (times.inject(:+) / times.size).to_i
109
- rescue
109
+ rescue
110
110
  end
111
111
  init.time ||= Time.now.to_i
112
112
 
113
113
  init
114
114
  end
115
-
115
+
116
116
  def self.mode(array)
117
117
  array.inject(Hash.new(0)) do |counts, e|
118
118
  counts[e] += 1
@@ -152,7 +152,7 @@ module Riemann
152
152
  def initialize(hash = nil)
153
153
  if hash
154
154
  if hash[:metric]
155
- super hash.merge(metric_f: hash[:metric])
155
+ super hash.merge(:metric_f => hash[:metric])
156
156
  else
157
157
  super hash
158
158
  end
@@ -1,3 +1,3 @@
1
1
  module Riemann
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
data/lib/riemann.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Riemann
2
2
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
3
3
 
4
+ require 'rubygems'
4
5
  require 'beefcake'
5
6
  require 'riemann/version'
6
7
  require 'riemann/state'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000 Z
12
+ date: 2012-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake
16
- requirement: &15270360 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.3.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *15270360
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.3.5
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: trollop
27
- requirement: &15269600 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 1.16.2
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *15269600
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.16.2
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: mtrc
38
- requirement: &15268880 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,23 +53,28 @@ dependencies:
43
53
  version: 0.0.4
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *15268880
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.4
47
62
  description:
48
63
  email: aphyr@aphyr.com
49
64
  executables: []
50
65
  extensions: []
51
66
  extra_rdoc_files: []
52
67
  files:
68
+ - lib/riemann/version.rb
53
69
  - lib/riemann/event.rb
54
- - lib/riemann/message.rb
55
70
  - lib/riemann/auto_state.rb
56
- - lib/riemann/metric_thread.rb
57
- - lib/riemann/version.rb
58
- - lib/riemann/state.rb
59
71
  - lib/riemann/query.rb
60
72
  - lib/riemann/client/udp.rb
61
73
  - lib/riemann/client/tcp.rb
74
+ - lib/riemann/metric_thread.rb
62
75
  - lib/riemann/client.rb
76
+ - lib/riemann/state.rb
77
+ - lib/riemann/message.rb
63
78
  - lib/riemann.rb
64
79
  - LICENSE
65
80
  - README.markdown
@@ -83,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
98
  version: '0'
84
99
  requirements: []
85
100
  rubyforge_project: riemann-client
86
- rubygems_version: 1.8.10
101
+ rubygems_version: 1.8.22
87
102
  signing_key:
88
103
  specification_version: 3
89
104
  summary: Client for the distributed event system Riemann.