kurchatov 0.0.5.pre5 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/README.md +6 -7
- data/Rakefile +1 -1
- data/Vagrantfile +5 -6
- data/bin/kurchatov +2 -2
- data/examples/check_file_contains.rb +4 -4
- data/examples/count_proc.rb +5 -5
- data/examples/cpu.rb +5 -5
- data/examples/disk.rb +3 -3
- data/examples/disk_stat.rb +6 -6
- data/examples/dns_check.rb +2 -2
- data/examples/exim.rb +1 -1
- data/examples/file_age.rb +5 -5
- data/examples/find_files.rb +1 -1
- data/examples/http.rb +3 -3
- data/examples/iptables.rb +3 -3
- data/examples/la.rb +12 -12
- data/examples/mdadm.rb +1 -1
- data/examples/memory.rb +8 -8
- data/examples/net.rb +6 -6
- data/examples/net_stat.rb +4 -4
- data/examples/nfs.rb +2 -2
- data/examples/nginx.rb +1 -1
- data/examples/nginx_500.rb +8 -8
- data/examples/ntp.rb +5 -5
- data/examples/openfiles.rb +2 -2
- data/examples/pgsql.rb +3 -3
- data/examples/ping_icmp.rb +4 -4
- data/examples/ping_tcp.rb +4 -4
- data/examples/proc_mem.rb +6 -6
- data/examples/rabbitmq.rb +4 -4
- data/examples/runit.rb +1 -1
- data/examples/sidekiq.rb +12 -12
- data/examples/sidekiq_queue_state.rb +3 -3
- data/examples/status_file.rb +4 -4
- data/examples/tw_cli.rb +4 -4
- data/examples/uptime.rb +4 -4
- data/kurchatov.gemspec +19 -18
- data/lib/kurchatov/application.rb +73 -74
- data/lib/kurchatov/mashie.rb +32 -27
- data/lib/kurchatov/mixin/command.rb +0 -5
- data/lib/kurchatov/mixin/event.rb +7 -5
- data/lib/kurchatov/mixin/http.rb +4 -4
- data/lib/kurchatov/mixin/init.rb +5 -5
- data/lib/kurchatov/mixin/ohai.rb +11 -3
- data/lib/kurchatov/mixin/queue.rb +7 -4
- data/lib/kurchatov/plugin/config.rb +8 -7
- data/lib/kurchatov/plugin/dsl.rb +3 -1
- data/lib/kurchatov/plugin/riemann.rb +7 -8
- data/lib/kurchatov/responders/http.rb +6 -6
- data/lib/kurchatov/responders/init.rb +3 -3
- data/lib/kurchatov/responders/riemann.rb +2 -4
- data/lib/kurchatov/responders/udp.rb +2 -3
- data/lib/kurchatov/riemann/client.rb +12 -12
- data/lib/kurchatov/riemann/event.rb +1 -1
- data/lib/kurchatov/riemann/message.rb +2 -2
- data/lib/kurchatov/version.rb +1 -1
- data/lib/kurchatov.rb +4 -2
- data/lib/ohai/plugins/darwin/cpu.rb +3 -3
- data/lib/ohai/plugins/darwin/hostname.rb +3 -3
- data/lib/ohai/plugins/darwin/platform.rb +12 -12
- data/lib/ohai/plugins/hostname.rb +2 -2
- data/lib/ohai/plugins/linux/cpu.rb +29 -29
- data/lib/ohai/plugins/linux/hostname.rb +4 -4
- data/lib/ohai/plugins/linux/platform.rb +40 -40
- data/lib/ohai/plugins/linux/virtualization.rb +51 -51
- data/lib/ohai/plugins/os.rb +26 -26
- data/lib/ohai/plugins/platform.rb +4 -4
- data/lib/ohai/plugins/virtualization.rb +17 -17
- data/lib/ohai/plugins/windows/cpu.rb +11 -11
- data/lib/ohai/plugins/windows/platform.rb +1 -1
- data/tests/run.sh +4 -4
- data/tests/server.rb +2 -2
- metadata +18 -3
data/examples/status_file.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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 =>
|
4
|
+
collect :os => 'linux' do
|
5
5
|
event(
|
6
|
-
|
6
|
+
:metric => File.read('/proc/uptime').split(' ').first.to_f
|
7
7
|
)
|
8
8
|
end
|
9
9
|
|
10
|
-
collect :os =>
|
10
|
+
collect :os => 'darwin' do
|
11
11
|
event(
|
12
|
-
|
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
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
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
|
17
|
-
spec.executables
|
18
|
-
spec.test_files
|
19
|
-
spec.require_paths = [
|
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
|
22
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'beefcake', '>= 0.3.5'
|
22
|
+
spec.add_dependency 'ohai', '>= 6.20.0'
|
23
23
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
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
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
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
|
14
|
+
class Application
|
15
15
|
include Mixlib::CLI
|
16
16
|
include Kurchatov::Mixin::Ohai
|
17
17
|
|
18
18
|
option :help,
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
42
|
+
:short => '-L LOGLOCATION',
|
43
|
+
:long => '--logfile LOGLOCATION',
|
44
|
+
:description => 'Set the log file location'
|
45
45
|
|
46
46
|
option :test_plugin,
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
:short => '-T FILE',
|
48
|
+
:long => '--test-plugin FILE',
|
49
|
+
:description => 'Test plugin'
|
50
50
|
|
51
51
|
option :config_file,
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
:short => '-c FILE',
|
53
|
+
:long => '--config FILE',
|
54
|
+
:description => 'Config file'
|
55
55
|
|
56
56
|
option :plugin_paths,
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
69
|
+
:long => '--host HOSTNAME',
|
70
|
+
:description => 'Set hostname for events',
|
71
|
+
:proc => lambda { |l| l.split(',') }
|
72
72
|
|
73
73
|
option :tags,
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
87
|
-
|
86
|
+
:long => '--http 0.0.0.0:55755',
|
87
|
+
:description => 'Set http responder for information'
|
88
88
|
|
89
89
|
option :udp_responder,
|
90
|
-
|
91
|
-
|
90
|
+
:long => '--udp 0.0.0.0:55955',
|
91
|
+
:description => 'Set udp responder for information'
|
92
92
|
|
93
93
|
option :stop_on_error,
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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] = [
|
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(
|
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(
|
122
|
+
@monitor << Responders::Udp.new(Config[:udp_responder])
|
124
123
|
end
|
125
124
|
if Config[:http_responder]
|
126
|
-
@monitor << Responders::Http.new(
|
125
|
+
@monitor << Responders::Http.new(Config[:http_responder])
|
127
126
|
end
|
128
|
-
@monitor << Responders::Riemann.new(
|
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
|
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
|
data/lib/kurchatov/mashie.rb
CHANGED
@@ -5,14 +5,16 @@ class Mashie < Hash
|
|
5
5
|
default ? super(default) : super(&blk)
|
6
6
|
end
|
7
7
|
|
8
|
-
class << self;
|
8
|
+
class << self;
|
9
|
+
alias [] new;
|
10
|
+
end
|
9
11
|
|
10
12
|
def id #:nodoc:
|
11
|
-
self[
|
13
|
+
self['id']
|
12
14
|
end
|
13
15
|
|
14
16
|
def type #:nodoc:
|
15
|
-
self[
|
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
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
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
|
@@ -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
|
-
|
7
|
-
|
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
|
14
|
+
return unless normalize_event(hash)
|
13
15
|
events << hash
|
14
16
|
end
|
15
17
|
|
16
18
|
protected
|
17
19
|
|
18
|
-
def
|
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]
|
data/lib/kurchatov/mixin/http.rb
CHANGED
data/lib/kurchatov/mixin/init.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
1
|
+
require_relative 'command'
|
2
|
+
require_relative 'http'
|
3
|
+
require_relative 'ohai'
|
4
|
+
require_relative 'queue'
|
5
|
+
require_relative 'event'
|
data/lib/kurchatov/mixin/ohai.rb
CHANGED
@@ -3,18 +3,26 @@ module Kurchatov
|
|
3
3
|
module Ohai
|
4
4
|
def self.data
|
5
5
|
@ohai ||= ::Ohai::System.new
|
6
|
-
|
7
|
-
@
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
require "kurchatov/queue"
|
1
|
+
require 'kurchatov/queue'
|
4
2
|
|
5
3
|
module Kurchatov
|
6
4
|
module Mixin
|
7
5
|
module Queue
|
8
|
-
|
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
|
2
|
-
require
|
3
|
-
require
|
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
|
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
|
-
|
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.
|
64
|
+
Log.info("Start plugins: #{@plugins_to_run.inspect}")
|
64
65
|
@plugins_to_run
|
65
66
|
end
|
66
67
|
|
data/lib/kurchatov/plugin/dsl.rb
CHANGED
@@ -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
|
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
|