riemann-babbler 0.5.5 → 0.5.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.
data/bin/riemann-babbler CHANGED
@@ -79,10 +79,6 @@ unless configatron.plugins.files.nil?
79
79
  end
80
80
  end
81
81
 
82
- # патч на dns resolv
83
- ipaddress = Resolv.new.getaddresses(configatron.riemann.host)
84
- configatron.riemann.host = ipaddress[rand(ipaddress.length)]
85
-
86
82
  # start plugins
87
83
  plugins.each { |plugin| require plugin }
88
84
 
@@ -92,7 +88,7 @@ plugin_threads = Riemann::Babbler.registered_plugins.map do |plugin|
92
88
  }
93
89
  end
94
90
 
95
- Signal.trap "USR2" do # перехватываем сообщение (на будущее)
91
+ Signal.trap "TERM" do # перехватываем сообщение (на будущее)
96
92
  plugin_threads.each( &:kill )
97
93
  end
98
94
 
data/config.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  riemann:
2
2
  host: localhost
3
3
  port: 5555
4
+ dns_ttl: 120
4
5
 
5
6
  logger:
6
7
  level: WARN
@@ -26,6 +26,9 @@ module Riemann
26
26
  @configatron = configatron
27
27
  @logger = logger
28
28
  @storage = Hash.new
29
+ @configatron.riemann.cache_host = Configatron::Dynamic.new{ riemann_ip }
30
+ @configatron.riemann.last_cache_time = Time.now
31
+ @riemann_ip = riemann_random_ip
29
32
  init
30
33
  run
31
34
  end
@@ -41,9 +44,22 @@ module Riemann
41
44
  end
42
45
  alias :opts :options
43
46
 
47
+ def riemann_ip
48
+ if Time.now - options.riemann.last_cache_time > options.riemann.dns_ttl
49
+ options.riemann.last_cache_time = Time.now
50
+ @riemann_ip = riemann_random_ip
51
+ end
52
+ @riemann_ip
53
+ end
54
+
55
+ def riemann_random_ip
56
+ ipaddress = Resolv.new.getaddresses(configatron.riemann.host)
57
+ ipaddress[rand(ipaddress.length)]
58
+ end
59
+
44
60
  def riemann
45
61
  @riemann ||= Riemann::Client.new(
46
- :host => options.riemann.host,
62
+ :host => options.riemann.cache_host,
47
63
  :port => options.riemann.port
48
64
  )
49
65
  end
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '0.5.5'
3
+ VERSION = '0.5.6'
4
4
  end
5
5
  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: 0.5.5
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -164,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  segments:
166
166
  - 0
167
- hash: 3108950723921484230
167
+ hash: -4231455956657341224
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements: