kurchatov 0.0.5.pre5 → 0.0.5

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +1 -0
  3. data/README.md +6 -7
  4. data/Rakefile +1 -1
  5. data/Vagrantfile +5 -6
  6. data/bin/kurchatov +2 -2
  7. data/examples/check_file_contains.rb +4 -4
  8. data/examples/count_proc.rb +5 -5
  9. data/examples/cpu.rb +5 -5
  10. data/examples/disk.rb +3 -3
  11. data/examples/disk_stat.rb +6 -6
  12. data/examples/dns_check.rb +2 -2
  13. data/examples/exim.rb +1 -1
  14. data/examples/file_age.rb +5 -5
  15. data/examples/find_files.rb +1 -1
  16. data/examples/http.rb +3 -3
  17. data/examples/iptables.rb +3 -3
  18. data/examples/la.rb +12 -12
  19. data/examples/mdadm.rb +1 -1
  20. data/examples/memory.rb +8 -8
  21. data/examples/net.rb +6 -6
  22. data/examples/net_stat.rb +4 -4
  23. data/examples/nfs.rb +2 -2
  24. data/examples/nginx.rb +1 -1
  25. data/examples/nginx_500.rb +8 -8
  26. data/examples/ntp.rb +5 -5
  27. data/examples/openfiles.rb +2 -2
  28. data/examples/pgsql.rb +3 -3
  29. data/examples/ping_icmp.rb +4 -4
  30. data/examples/ping_tcp.rb +4 -4
  31. data/examples/proc_mem.rb +6 -6
  32. data/examples/rabbitmq.rb +4 -4
  33. data/examples/runit.rb +1 -1
  34. data/examples/sidekiq.rb +12 -12
  35. data/examples/sidekiq_queue_state.rb +3 -3
  36. data/examples/status_file.rb +4 -4
  37. data/examples/tw_cli.rb +4 -4
  38. data/examples/uptime.rb +4 -4
  39. data/kurchatov.gemspec +19 -18
  40. data/lib/kurchatov/application.rb +73 -74
  41. data/lib/kurchatov/mashie.rb +32 -27
  42. data/lib/kurchatov/mixin/command.rb +0 -5
  43. data/lib/kurchatov/mixin/event.rb +7 -5
  44. data/lib/kurchatov/mixin/http.rb +4 -4
  45. data/lib/kurchatov/mixin/init.rb +5 -5
  46. data/lib/kurchatov/mixin/ohai.rb +11 -3
  47. data/lib/kurchatov/mixin/queue.rb +7 -4
  48. data/lib/kurchatov/plugin/config.rb +8 -7
  49. data/lib/kurchatov/plugin/dsl.rb +3 -1
  50. data/lib/kurchatov/plugin/riemann.rb +7 -8
  51. data/lib/kurchatov/responders/http.rb +6 -6
  52. data/lib/kurchatov/responders/init.rb +3 -3
  53. data/lib/kurchatov/responders/riemann.rb +2 -4
  54. data/lib/kurchatov/responders/udp.rb +2 -3
  55. data/lib/kurchatov/riemann/client.rb +12 -12
  56. data/lib/kurchatov/riemann/event.rb +1 -1
  57. data/lib/kurchatov/riemann/message.rb +2 -2
  58. data/lib/kurchatov/version.rb +1 -1
  59. data/lib/kurchatov.rb +4 -2
  60. data/lib/ohai/plugins/darwin/cpu.rb +3 -3
  61. data/lib/ohai/plugins/darwin/hostname.rb +3 -3
  62. data/lib/ohai/plugins/darwin/platform.rb +12 -12
  63. data/lib/ohai/plugins/hostname.rb +2 -2
  64. data/lib/ohai/plugins/linux/cpu.rb +29 -29
  65. data/lib/ohai/plugins/linux/hostname.rb +4 -4
  66. data/lib/ohai/plugins/linux/platform.rb +40 -40
  67. data/lib/ohai/plugins/linux/virtualization.rb +51 -51
  68. data/lib/ohai/plugins/os.rb +26 -26
  69. data/lib/ohai/plugins/platform.rb +4 -4
  70. data/lib/ohai/plugins/virtualization.rb +17 -17
  71. data/lib/ohai/plugins/windows/cpu.rb +11 -11
  72. data/lib/ohai/plugins/windows/platform.rb +1 -1
  73. data/tests/run.sh +4 -4
  74. data/tests/server.rb +2 -2
  75. metadata +18 -3
@@ -6,9 +6,9 @@ default[:service] = 'check state file'
6
6
  collect do
7
7
  content = File.read(plugin.file).split("\n").delete_if { |x| x.strip.empty? }
8
8
  event(
9
- :service => "#{plugin.service} #{plugin.file}",
10
- :description => content.last(plugin.report_lines).join("\n"),
11
- :metric => content.count,
12
- :critical => 1
9
+ :service => "#{plugin.service} #{plugin.file}",
10
+ :description => content.last(plugin.report_lines).join("\n"),
11
+ :metric => content.count,
12
+ :critical => 1
13
13
  )
14
14
  end
data/examples/tw_cli.rb CHANGED
@@ -9,9 +9,9 @@ end
9
9
 
10
10
  collect do
11
11
  event(
12
- :service => 'twcli',
13
- :metric => shell(plugin.cmd).to_i,
14
- :description => 'Hardware raid tw_cli status',
15
- :critical => 1
12
+ :service => 'twcli',
13
+ :metric => shell(plugin.cmd).to_i,
14
+ :description => 'Hardware raid tw_cli status',
15
+ :critical => 1
16
16
  )
17
17
  end
data/examples/uptime.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  interval 60
2
2
  always_start true
3
3
 
4
- collect :os => "linux" do
4
+ collect :os => 'linux' do
5
5
  event(
6
- :metric => File.read('/proc/uptime').split(' ').first.to_f
6
+ :metric => File.read('/proc/uptime').split(' ').first.to_f
7
7
  )
8
8
  end
9
9
 
10
- collect :os => "darwin" do
10
+ collect :os => 'darwin' do
11
11
  event(
12
- :metric => shell("sysctl -n kern.boottime | awk '{print $4}'").to_f
12
+ :metric => shell("sysctl -n kern.boottime | awk '{print $4}'").to_f
13
13
  )
14
14
  end
data/kurchatov.gemspec CHANGED
@@ -4,25 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'kurchatov/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "kurchatov"
8
- spec.version = Kurchatov::VERSION
9
- spec.authors = ["Vasiliev Dmitry"]
10
- spec.email = ["vadv.mkn@gmail.com"]
11
- spec.summary = %q{Gem for monitoring with riemann.}
12
- spec.description = %q{Gem for monitoring with riemann.}
13
- spec.homepage = "https://github.com/vadv/kurchatov"
14
- spec.license = "MIT"
7
+ spec.name = 'kurchatov'
8
+ spec.version = Kurchatov::VERSION
9
+ spec.authors = ['Vasiliev Dmitry']
10
+ spec.email = ['vadv.mkn@gmail.com']
11
+ spec.summary = %q{Gem for monitoring with riemann.}
12
+ spec.description = %q{Gem for monitoring with riemann.}
13
+ spec.homepage = 'https://github.com/vadv/kurchatov'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency "beefcake", ">= 0.3.5"
22
- spec.add_dependency "ohai", ">= 6.20.0"
21
+ spec.add_dependency 'beefcake', '>= 0.3.5'
22
+ spec.add_dependency 'ohai', '>= 6.20.0'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.5"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "pry"
27
- spec.add_development_dependency "ruby-prof"
24
+ spec.add_development_dependency 'bundler', '~> 1.5'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'pry'
28
+ spec.add_development_dependency 'ruby-prof'
28
29
  end
@@ -1,100 +1,100 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "ohai/system"
4
- require "mixlib/cli"
5
- require "kurchatov/version"
6
- require "kurchatov/config"
7
- require "kurchatov/log"
8
- require "kurchatov/mixin/init"
9
- require "kurchatov/plugin/config"
10
- require "kurchatov/responders/init"
11
- require "kurchatov/monitor"
3
+ require 'ohai/system'
4
+ require 'mixlib/cli'
5
+ require 'kurchatov/version'
6
+ require 'kurchatov/config'
7
+ require 'kurchatov/log'
8
+ require 'kurchatov/mixin/init'
9
+ require 'kurchatov/plugin/config'
10
+ require 'kurchatov/responders/init'
11
+ require 'kurchatov/monitor'
12
12
 
13
13
  module Kurchatov
14
- class Aplication
14
+ class Application
15
15
  include Mixlib::CLI
16
16
  include Kurchatov::Mixin::Ohai
17
17
 
18
18
  option :help,
19
- :short => "-h",
20
- :long => "--help",
21
- :description => "Show this message",
22
- :on => :tail,
23
- :boolean => true,
24
- :show_options => true,
25
- :exit => 1
19
+ :short => '-h',
20
+ :long => '--help',
21
+ :description => 'Show this message',
22
+ :on => :tail,
23
+ :boolean => true,
24
+ :show_options => true,
25
+ :exit => 1
26
26
 
27
27
  option :version,
28
- :short => "-v",
29
- :long => "--version",
30
- :description => "Show version",
31
- :boolean => true,
32
- :proc => lambda {|v| puts "Kurchatov: #{Kurchatov::VERSION}"},
33
- :exit => 0
28
+ :short => '-v',
29
+ :long => '--version',
30
+ :description => 'Show version',
31
+ :boolean => true,
32
+ :proc => lambda { |v| puts "Kurchatov: #{Kurchatov::VERSION}" },
33
+ :exit => 0
34
34
 
35
35
  option :log_level,
36
- :short => "-l LEVEL",
37
- :long => "--log_level LEVEL",
38
- :description => "Set the log level (debug, info, warn, error, fatal)",
39
- :proc => lambda {|l| l.to_sym}
36
+ :short => '-l LEVEL',
37
+ :long => '--log_level LEVEL',
38
+ :description => 'Set the log level (debug, info, warn, error, fatal)',
39
+ :proc => lambda { |l| l.to_sym }
40
40
 
41
41
  option :log_location,
42
- :short => "-L LOGLOCATION",
43
- :long => "--logfile LOGLOCATION",
44
- :description => "Set the log file location"
42
+ :short => '-L LOGLOCATION',
43
+ :long => '--logfile LOGLOCATION',
44
+ :description => 'Set the log file location'
45
45
 
46
46
  option :test_plugin,
47
- :short => "-T FILE",
48
- :long => "--test-plugin FILE",
49
- :description => "Test plugin"
47
+ :short => '-T FILE',
48
+ :long => '--test-plugin FILE',
49
+ :description => 'Test plugin'
50
50
 
51
51
  option :config_file,
52
- :short => "-c FILE",
53
- :long => "--config FILE",
54
- :description => "Config file"
52
+ :short => '-c FILE',
53
+ :long => '--config FILE',
54
+ :description => 'Config file'
55
55
 
56
56
  option :plugin_paths,
57
- :short => "-d DIR1,DIR2",
58
- :long => "--plugins DIR1,DIR2",
59
- :description => "Plugin directories",
60
- :proc => lambda {|l| l.split(',') }
57
+ :short => '-d DIR1,DIR2',
58
+ :long => '--plugins DIR1,DIR2',
59
+ :description => 'Plugin directories',
60
+ :proc => lambda { |l| l.split(',') }
61
61
 
62
62
  option :ohai_plugins_paths,
63
- :short => "-o DIR1,DIR2",
64
- :long => "--ohai--plugins DIR1,DIR2",
65
- :description => "Plugin directories",
66
- :proc => lambda {|l| l.split(',') }
63
+ :short => '-o DIR1,DIR2',
64
+ :long => '--ohai--plugins DIR1,DIR2',
65
+ :description => 'Plugin directories',
66
+ :proc => lambda { |l| l.split(',') }
67
67
 
68
68
  option :host,
69
- :long => "--host HOSTNAME",
70
- :description => "Set hostname for events",
71
- :proc => lambda {|l| l.split(',') }
69
+ :long => '--host HOSTNAME',
70
+ :description => 'Set hostname for events',
71
+ :proc => lambda { |l| l.split(',') }
72
72
 
73
73
  option :tags,
74
- :short => "-t tag1,tag2,tag3",
75
- :long => "--tags tag1,tag2,tag3",
76
- :description => "Set tags for events",
77
- :proc => lambda {|l| l.split(',') }
74
+ :short => '-t tag1,tag2,tag3',
75
+ :long => '--tags tag1,tag2,tag3',
76
+ :description => 'Set tags for events',
77
+ :proc => lambda { |l| l.split(',') }
78
78
 
79
79
  option :riemann_responder,
80
- :short => "-H HOST1,HOST2:55655",
81
- :long => "--hosts HOST1,HOST2:55655",
82
- :description => "Set riemann hosts for send events",
83
- :proc => lambda {|l| l.split(',') }
80
+ :short => '-H HOST1,HOST2:55655',
81
+ :long => '--hosts HOST1,HOST2:55655',
82
+ :description => 'Set riemann hosts for send events',
83
+ :proc => lambda { |l| l.split(',') }
84
84
 
85
85
  option :http_responder,
86
- :long => "--http 0.0.0.0:55755",
87
- :description => "Set http responder for information"
86
+ :long => '--http 0.0.0.0:55755',
87
+ :description => 'Set http responder for information'
88
88
 
89
89
  option :udp_responder,
90
- :long => "--udp 0.0.0.0:55955",
91
- :description => "Set udp responder for information"
90
+ :long => '--udp 0.0.0.0:55955',
91
+ :description => 'Set udp responder for information'
92
92
 
93
93
  option :stop_on_error,
94
- :long => "--stop-on-error",
95
- :description => "Stop on plugin or connection problem",
96
- :boolean => true,
97
- :proc => lambda {|l| !!l }
94
+ :long => '--stop-on-error',
95
+ :description => 'Stop on plugin or connection problem',
96
+ :boolean => true,
97
+ :proc => lambda { |l| !!l }
98
98
 
99
99
  def configure_opts
100
100
  @attributes = parse_options
@@ -108,7 +108,7 @@ module Kurchatov
108
108
  end
109
109
 
110
110
  def configure_defaults
111
- ::Ohai::Config[:plugin_path] = [ File.expand_path(File.join('..', 'ohai', 'plugins'), File.dirname(__FILE__)) ]
111
+ ::Ohai::Config[:plugin_path] = [File.expand_path(File.join('..', 'ohai', 'plugins'), File.dirname(__FILE__))]
112
112
  if Config[:ohai_plugins_paths]
113
113
  ::Ohai::Config[:plugin_path] += Config[:ohai_plugins_paths]
114
114
  end
@@ -117,26 +117,25 @@ module Kurchatov
117
117
 
118
118
  def configure_responders
119
119
  return if Config[:test_plugin]
120
- Log.error("Please set riemann host") and exit Config[:ERROR_CONFIG] unless
121
- Config[:riemann_responder]
120
+ Log.error('Please set riemann host') and exit Config[:ERROR_CONFIG] unless Config[:riemann_responder]
122
121
  if Config[:udp_responder]
123
- @monitor << Responders::Udp.new( Config[:udp_responder] )
122
+ @monitor << Responders::Udp.new(Config[:udp_responder])
124
123
  end
125
124
  if Config[:http_responder]
126
- @monitor << Responders::Http.new( Config[:http_responder] )
125
+ @monitor << Responders::Http.new(Config[:http_responder])
127
126
  end
128
- @monitor << Responders::Riemann.new( Config[:riemann_responder] )
129
- end
127
+ @monitor << Responders::Riemann.new(Config[:riemann_responder])
128
+ end
130
129
 
131
130
  def configure_plugins
132
131
  return if Config[:test_plugin]
133
- plugins = Kurchatov::Plugins::Config.load_plugins(Config[:plugin_paths],
132
+ plugins = Kurchatov::Plugins::Config.load_plugins(Config[:plugin_paths],
134
133
  Config[:config_file])
135
- plugins.each {|p| @monitor << p }
134
+ plugins.each { |p| @monitor << p }
136
135
  end
137
136
 
138
137
  def configure_test_plugin
139
- return if !Config[:test_plugin]
138
+ return unless Config[:test_plugin]
140
139
  @monitor << Kurchatov::Plugins::DSL.load_riemann_plugin(Config[:test_plugin])
141
140
  end
142
141
 
@@ -150,6 +149,6 @@ module Kurchatov
150
149
  configure_test_plugin
151
150
  @monitor.run
152
151
  end
153
-
152
+
154
153
  end
155
154
  end
@@ -5,14 +5,16 @@ class Mashie < Hash
5
5
  default ? super(default) : super(&blk)
6
6
  end
7
7
 
8
- class << self; alias [] new; end
8
+ class << self;
9
+ alias [] new;
10
+ end
9
11
 
10
12
  def id #:nodoc:
11
- self["id"]
13
+ self['id']
12
14
  end
13
15
 
14
16
  def type #:nodoc:
15
- self["type"]
17
+ self['type']
16
18
  end
17
19
 
18
20
  alias_method :regular_reader, :[]
@@ -24,7 +26,7 @@ class Mashie < Hash
24
26
  value
25
27
  end
26
28
 
27
- def custom_writer(key,value) #:nodoc:
29
+ def custom_writer(key, value) #:nodoc:
28
30
  regular_writer(convert_key(key), convert_value(value))
29
31
  end
30
32
 
@@ -63,6 +65,7 @@ class Mashie < Hash
63
65
  def key?(key)
64
66
  super(convert_key(key))
65
67
  end
68
+
66
69
  alias_method :has_key?, :key?
67
70
  alias_method :include?, :key?
68
71
  alias_method :member?, :key?
@@ -70,10 +73,11 @@ class Mashie < Hash
70
73
  def deep_merge(other_hash, &blk)
71
74
  dup.deep_update(other_hash, &blk)
72
75
  end
76
+
73
77
  alias_method :merge, :deep_merge
74
78
 
75
79
  def deep_update(other_hash, &blk)
76
- other_hash.each_pair do |k,v|
80
+ other_hash.each_pair do |k, v|
77
81
  key = convert_key(k)
78
82
  if regular_reader(key).is_a?(Mash) and v.is_a?(::Hash)
79
83
  custom_reader(key).deep_update(v, &blk)
@@ -85,6 +89,7 @@ class Mashie < Hash
85
89
  end
86
90
  self
87
91
  end
92
+
88
93
  alias_method :deep_merge!, :deep_update
89
94
  alias_method :update, :deep_update
90
95
  alias_method :merge!, :update
@@ -94,7 +99,7 @@ class Mashie < Hash
94
99
  end
95
100
 
96
101
  def shallow_update(other_hash)
97
- other_hash.each_pair do |k,v|
102
+ other_hash.each_pair do |k, v|
98
103
  regular_writer(convert_key(k), convert_value(v, true))
99
104
  end
100
105
  self
@@ -115,16 +120,16 @@ class Mashie < Hash
115
120
  return self.[](method_name, &blk) if key?(method_name)
116
121
  match = method_name.to_s.match(/(.*?)([?=!_]?)$/)
117
122
  case match[2]
118
- when "="
119
- self[match[1]] = args.first
120
- when "?"
121
- !!self[match[1]]
122
- when "!"
123
- initializing_reader(match[1])
124
- when "_"
125
- underbang_reader(match[1])
126
- else
127
- default(method_name, *args, &blk)
123
+ when '='
124
+ self[match[1]] = args.first
125
+ when '?'
126
+ !!self[match[1]]
127
+ when '!'
128
+ initializing_reader(match[1])
129
+ when '_'
130
+ underbang_reader(match[1])
131
+ else
132
+ default(method_name, *args, &blk)
128
133
  end
129
134
  end
130
135
 
@@ -136,17 +141,17 @@ class Mashie < Hash
136
141
 
137
142
  def convert_value(val, duping=false) #:nodoc:
138
143
  case val
139
- when self.class
140
- val.dup
141
- when Hash
142
- duping ? val.dup : val
143
- when ::Hash
144
- val = val.dup if duping
145
- self.class.new(val)
146
- when Array
147
- val.collect{ |e| convert_value(e) }
148
- else
149
- val
144
+ when self.class
145
+ val.dup
146
+ when Hash
147
+ duping ? val.dup : val
148
+ when ::Hash
149
+ val = val.dup if duping
150
+ self.class.new(val)
151
+ when Array
152
+ val.collect { |e| convert_value(e) }
153
+ else
154
+ val
150
155
  end
151
156
  end
152
157
  end
@@ -19,11 +19,6 @@ module Kurchatov
19
19
  mix.stdout
20
20
  end
21
21
 
22
- def print_unix_mem_info
23
- pid, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`.strip.split.map(&:to_i)
24
- puts "Pid: #{pid}, memusage: #{size}"
25
- end
26
-
27
22
  end
28
23
  end
29
24
  end
@@ -2,20 +2,22 @@ module Kurchatov
2
2
  module Mixin
3
3
  module Event
4
4
 
5
+ include Kurchatov::Mixin::Queue
6
+
5
7
  EVENT_FIELDS = [
6
- :time, :state, :service, :host,
7
- :description, :tags, :ttl, :metric
8
+ :time, :state, :service, :host,
9
+ :description, :tags, :ttl, :metric
8
10
  ]
9
11
 
10
12
  def event(hash = {})
11
13
  Log.info("Mock message for test plugin: #{hash.inspect}") if Kurchatov::Config[:test_plugin]
12
- return unless normilize_event(hash)
14
+ return unless normalize_event(hash)
13
15
  events << hash
14
16
  end
15
17
 
16
18
  protected
17
19
 
18
- def normilize_event(hash = {})
20
+ def normalize_event(hash = {})
19
21
  hash[:description] = hash[:desc] if hash[:description].nil? && hash[:desc]
20
22
  if hash[:metric].kind_of?(Float)
21
23
  hash[:metric] = 0.0 if hash[:metric].nan?
@@ -24,7 +26,7 @@ module Kurchatov
24
26
  set_diff_metric(hash)
25
27
  set_event_state(hash)
26
28
  return false if hash[:miss]
27
- hash.each {|k,_| hash.delete(k) unless EVENT_FIELDS.include?(k)}
29
+ hash.each { |k, _| hash.delete(k) unless EVENT_FIELDS.include?(k) }
28
30
  hash[:service] ||= name
29
31
  hash[:tags] ||= Kurchatov::Config[:tags]
30
32
  hash[:host] ||= Kurchatov::Config[:host]
@@ -1,5 +1,5 @@
1
- require "open-uri"
2
- require "yajl/json_gem"
1
+ require 'open-uri'
2
+ require 'yajl/json_gem'
3
3
 
4
4
  module Kurchatov
5
5
  module Mixin
@@ -16,6 +16,6 @@ module Kurchatov
16
16
  end
17
17
  end
18
18
 
19
- end
20
- end
19
+ end
20
+ end
21
21
  end
@@ -1,5 +1,5 @@
1
- require_relative "command"
2
- require_relative "http"
3
- require_relative "ohai"
4
- require_relative "queue"
5
- require_relative "event"
1
+ require_relative 'command'
2
+ require_relative 'http'
3
+ require_relative 'ohai'
4
+ require_relative 'queue'
5
+ require_relative 'event'
@@ -3,18 +3,26 @@ module Kurchatov
3
3
  module Ohai
4
4
  def self.data
5
5
  @ohai ||= ::Ohai::System.new
6
- Log.info("Load ohai plugins")
7
- @ohai.all_plugins
6
+ @mutex ||= Mutex.new
7
+ @mutex.synchronize do
8
+ Log.info('Load ohai plugins')
9
+ @ohai.all_plugins
10
+ end
8
11
  @ohai.data
9
12
  end
10
13
  end
11
14
 
12
15
  module Mixin
13
16
  module Ohai
14
- class << self; attr_accessor :ohai_instance; end
17
+
18
+ class << self;
19
+ attr_accessor :ohai_instance;
20
+ end
21
+
15
22
  def ohai
16
23
  @ohai_instance ||= Kurchatov::Mixin::Ohai.ohai_instance ||= Kurchatov::Ohai.data
17
24
  end
25
+
18
26
  end
19
27
  end
20
28
 
@@ -1,14 +1,17 @@
1
- # encoding: utf-8
2
-
3
- require "kurchatov/queue"
1
+ require 'kurchatov/queue'
4
2
 
5
3
  module Kurchatov
6
4
  module Mixin
7
5
  module Queue
8
- class << self; attr_accessor :instance_queue end
6
+
7
+ class << self;
8
+ attr_accessor :instance_queue
9
+ end
10
+
9
11
  def events
10
12
  @instance_queue ||= Kurchatov::Mixin::Queue.instance_queue ||= Kurchatov::Queue.new
11
13
  end
14
+
12
15
  end
13
16
  end
14
17
  end
@@ -1,17 +1,18 @@
1
- require "kurchatov/plugin/riemann"
2
- require "kurchatov/plugin/dsl"
3
- require "yaml"
1
+ require 'kurchatov/plugin/riemann'
2
+ require 'kurchatov/plugin/dsl'
3
+ require 'yaml'
4
4
 
5
5
  module Kurchatov
6
6
  module Plugins
7
7
  module Config
8
8
 
9
9
  def self.find_plugin(name, array)
10
- array.find {|p| p.name == name }
10
+ array.find { |p| p.name == name }
11
11
  end
12
12
 
13
13
  def self.load_plugins(plugins_path, config_file)
14
- Log.error("Config file #{config_file} not found") and exit Kurchatov::Config[:ERROR_CONFIG] unless File.exists?(config_file)
14
+ Log.error("Config file #{config_file} not found") and
15
+ exit(Kurchatov::Config[:ERROR_CONFIG]) unless File.exists?(config_file)
15
16
  @all_plugins = Kurchatov::Plugins::DSL.load_riemann_plugins(plugins_path)
16
17
  @all_names = Array.new
17
18
  @plugins_to_run = Array.new
@@ -55,12 +56,12 @@ module Kurchatov
55
56
  @all_plugins.each do |p|
56
57
  unless p.always_start || @all_names.include?(p.name)
57
58
  Log.info("Plugin '#{p.name}' not started, because it " +
58
- "not 'always_start' and not in config file")
59
+ "not 'always_start' and not in config file")
59
60
  next
60
61
  end
61
62
  @plugins_to_run << p if p.runnable_by_config?
62
63
  end
63
- Log.debug("Plugins to start: #{@plugins_to_run.inspect}")
64
+ Log.info("Start plugins: #{@plugins_to_run.inspect}")
64
65
  @plugins_to_run
65
66
  end
66
67
 
@@ -49,6 +49,7 @@ module Kurchatov
49
49
  def last_plugin
50
50
  last.plugin
51
51
  end
52
+
52
53
  alias :default :last_plugin
53
54
 
54
55
 
@@ -57,7 +58,8 @@ module Kurchatov
57
58
  def self.load_riemann_plugins(paths)
58
59
  dsl = Kurchatov::Plugins::DSL.new
59
60
  paths.map do |path|
60
- Log.error("Directory #{path} not exists") and exit Kurchatov::Config[:ERROR_CONFIG] unless File.directory? path
61
+ Log.error("Directory #{path} not exists") and exit Kurchatov::Config[:ERROR_CONFIG] unless
62
+ File.directory?(path)
61
63
  Dir[File.join(path, "*#{PLUGIN_EXT}")].sort
62
64
  end.flatten.each do |path|
63
65
  begin