riemann-tools 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/riemann/tools.rb +13 -5
  2. metadata +2 -2
data/lib/riemann/tools.rb CHANGED
@@ -35,6 +35,7 @@ module Riemann
35
35
  opt :ttl, "TTL for events", :type => Integer
36
36
  opt :attribute, "Attribute to add to the event", :type => String, :multi => true
37
37
  opt :timeout, "Timeout (in seconds) when waiting for acknowledgements", :default => 30
38
+ opt :tcp, "Use TCP transport instead of UDP (improves reliability, slight overhead.", :default => true
38
39
  end
39
40
  end
40
41
 
@@ -59,9 +60,7 @@ module Riemann
59
60
  event[:tags] = options[:tag].map(&:dup)
60
61
  end
61
62
 
62
- if options[:ttl]
63
- event[:ttl] = options[:ttl]
64
- end
63
+ event[:ttl] ||= (options[:ttl] || (options[:interval] * 2))
65
64
 
66
65
  if options[:event_host]
67
66
  event[:host] = options[:event_host].dup
@@ -78,11 +77,20 @@ module Riemann
78
77
  end
79
78
  end
80
79
 
81
- def riemann
82
- @riemann ||= Riemann::Client.new(
80
+ def new_riemann_client
81
+ r = Riemann::Client.new(
83
82
  :host => options[:host],
84
83
  :port => options[:port]
85
84
  )
85
+ if options[:tcp]
86
+ r.tcp
87
+ else
88
+ r
89
+ end
90
+ end
91
+
92
+ def riemann
93
+ @riemann ||= new_riemann_client
86
94
  end
87
95
  alias :r :riemann
88
96
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-16 00:00:00.000000000 Z
12
+ date: 2013-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riemann-client