riemann-babbler 0.5.9 → 0.6.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.
data/bin/riemann-babbler CHANGED
@@ -79,12 +79,20 @@ unless configatron.plugins.files.nil?
79
79
  end
80
80
  end
81
81
 
82
+ # set riemann client
83
+ riemann_ip = Resolv.new.getaddress(configatron.riemann.host)
84
+ riemann = Riemann::Client.new(
85
+ :host => riemann_ip,
86
+ :port => configatron.riemann.port
87
+ )
88
+ riemann = ( configatron.riemann.proto == 'tcp' ) ? riemann.tcp : riemann
89
+
82
90
  # start plugins
83
91
  plugins.each { |plugin| require plugin }
84
92
 
85
93
  plugin_threads = Riemann::Babbler.registered_plugins.map do |plugin|
86
94
  Thread.new {
87
- plugin.new( configatron, logger ).run
95
+ plugin.new( configatron, logger, riemann ).run
88
96
  }
89
97
  end
90
98
 
data/config.yml CHANGED
@@ -1,10 +1,10 @@
1
1
  riemann:
2
- host: localhost
2
+ host: 127.0.0.1
3
3
  port: 5555
4
- dns_ttl: 120
4
+ proto: auto # auto use tcp + udp(max size 16384), tcp - tcp only
5
5
 
6
6
  logger:
7
- level: WARN
7
+ level: DEBUG
8
8
 
9
9
  plugins:
10
10
 
@@ -20,15 +20,16 @@ module Riemann
20
20
  require 'rest_client'
21
21
 
22
22
  attr_reader :logger
23
+ attr_reader :riemann
24
+ alias :r :riemann
23
25
  attr_reader :hostname
24
26
 
25
- def initialize( configatron, logger )
27
+ def initialize( configatron, logger, riemann )
26
28
  @configatron = configatron
27
29
  @logger = logger
30
+ @riemann = riemann
28
31
  @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
32
+ @hostname = get_hostname
32
33
  init
33
34
  run
34
35
  end
@@ -44,27 +45,6 @@ module Riemann
44
45
  end
45
46
  alias :opts :options
46
47
 
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
-
60
- def riemann
61
- @riemann ||= Riemann::Client.new(
62
- :host => options.riemann.cache_host,
63
- :port => options.riemann.port
64
- )
65
- end
66
- alias :r :riemann
67
-
68
48
  def report(event)
69
49
  report_with_diff(event) and return if event[:as_diff]
70
50
  # если нет event[:state] то попробовать его добавить
@@ -72,8 +52,9 @@ module Riemann
72
52
  event[:state] = state(event[:metric]) unless plugin.states.critical.nil?
73
53
  end
74
54
  event[:tags] = options.riemann.tags unless options.riemann.tags.nil?
75
- event[:host] = host
55
+ event[:host] = hostname
76
56
  logger.debug "Report status: #{event.inspect}"
57
+ logger.error "Riemann: #{riemann.inspect}"
77
58
  riemann << event
78
59
  end
79
60
 
@@ -85,10 +66,6 @@ module Riemann
85
66
  report(event)
86
67
  end
87
68
 
88
- def host
89
- @hostname ||= get_hostname
90
- end
91
-
92
69
  def get_hostname
93
70
  hostname = File.read('/proc/sys/kernel/hostname').strip.downcase
94
71
  hostname += options.riemann.suffix unless options.riemann.suffix.nil?
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '0.5.9'
3
+ VERSION = '0.6.0'
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.9
4
+ version: 0.6.0
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: 692322419942521535
167
+ hash: 1081513647507709696
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements: