kurchatov 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3491801f7a156bc9ac3b0b15f5b8ac349b5ea0c8
4
- data.tar.gz: 6bb3727bce6b21b51a3a227938a6a9f14c86852c
3
+ metadata.gz: 54bb6b67e8ca9aca95e11895ef1cb66645f0d68d
4
+ data.tar.gz: bcd522202de89b8fd81167443cb6bebf6bb00696
5
5
  SHA512:
6
- metadata.gz: 8e9f5becda3504f709e8f653776c410021ef99c457cbc2643ccb1d692d9cc255803dafcfbe0887eaec2e33065b76dff7b6621e3c763f013afb91cae28afa5c83
7
- data.tar.gz: 4d983e2443cc8ae526719f3c9718933ae486a71cdb67dc221940fe6fdaaac611188631d1bebb0295d7440554396b52ea9a3f47db136e39a535dd014b2dfe8b2e
6
+ metadata.gz: ac5c7fad5c2c5540c6e321b112906d54b88b05a69316231203927b0813a6080bf057a3e301acfd26c986cbcf1675df250650d952f67b35846a80203962fdfb80
7
+ data.tar.gz: 8e5c5a3770b22afa25740fb470b53576ee0cdc6003dfc94ef542b2806fc98c86d51ba767c4d2e19dbfaf6f027883b7330e277c08d1fa68e07d5452a182577800
data/.travis.yml CHANGED
@@ -1,9 +1,14 @@
1
+ language: ruby
2
+
1
3
  os:
2
4
  - linux
3
5
  - osx
6
+ - windows
4
7
 
5
- language:
6
- - ruby
8
+ before_install:
9
+ - date -u
10
+ - uname -a
11
+ - env | sort
7
12
 
8
13
  rvm:
9
14
  - 1.9.3
@@ -12,3 +17,7 @@ rvm:
12
17
  - 1.8.7
13
18
 
14
19
  script: "./tests/run.sh"
20
+
21
+ notifications:
22
+ email:
23
+ - vadv.mkn@gmail.com
@@ -90,12 +90,6 @@ module Kurchatov
90
90
  :long => '--udp 0.0.0.0:55955',
91
91
  :description => 'Set udp responder for information'
92
92
 
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 }
98
-
99
93
  def configure_opts
100
94
  @attributes = parse_options
101
95
  @attributes = nil if @attributes.empty?
@@ -7,6 +7,5 @@ module Kurchatov
7
7
  default :config_file, '/etc/kurchatov/config.yml'
8
8
  # errors
9
9
  default :ERROR_CONFIG, 2
10
- default :ERROR_PLUGIN_REQ, 3
11
10
  end
12
11
  end
@@ -10,7 +10,7 @@ module Kurchatov
10
10
 
11
11
  def monitor
12
12
  @instance_monitor ||= Kurchatov::Mixin::Monitor.instance_monitor ||=
13
- Kurchatov::Monitor.new(Kurchatov::Config[:stop_on_error] || !!Kurchatov::Config[:test_plugin])
13
+ Kurchatov::Monitor.new
14
14
  end
15
15
 
16
16
  end
@@ -40,7 +40,7 @@ module Kurchatov
40
40
  begin
41
41
  @thread.join # call error
42
42
  rescue => e
43
- desc = "Plugin '#{@plugin.name}' died. #{e.class}: #{e}\n." +
43
+ desc = "Plugin '#{@plugin.name}' died. #{e.class}: #{e}.\n" +
44
44
  "Trace: #{e.backtrace.join("\n")}"
45
45
  @count_errors += 1
46
46
  @last_error_count += 1
@@ -51,7 +51,6 @@ module Kurchatov
51
51
  event(:service => "plugin #{@plugin.name} errors", :desc => desc, :state => 'critical')
52
52
  end
53
53
  end
54
- start! #FIXME
55
54
  true
56
55
  end
57
56
 
@@ -64,34 +63,31 @@ module Kurchatov
64
63
  attr_accessor :tasks
65
64
  CHECK_ALIVE_TIMEOUT = 5
66
65
 
67
- def initialize(stop = false)
68
- @stop_on_error = stop
66
+ def initialize
69
67
  @tasks = Array.new
70
68
  end
71
69
 
72
70
  def <<(plugin)
73
71
  Log.debug("Add new plugin: #{plugin.inspect}")
74
- @tasks << Task.new(plugin)
72
+ tasks << Task.new(plugin)
75
73
  end
76
74
 
77
75
  def start!
78
76
  loop do
79
- @tasks.each do |task|
80
- if task.died? && @stop_on_error
81
- exit(Config[:ERROR_PLUGIN_REQ])
82
- end
77
+ tasks.each do |task|
78
+ task.start! if task.died?
83
79
  if task.stopped?
84
80
  task.stop!
85
- @tasks.delete(task)
81
+ tasks.delete(task)
86
82
  end
87
83
  end
88
- Log.debug("Check alive plugins [#{@tasks.count}]")
84
+ Log.debug("Check alive plugins [#{tasks.count}]")
89
85
  sleep CHECK_ALIVE_TIMEOUT
90
86
  end
91
87
  end
92
88
 
93
89
  def inspect
94
- @tasks.map do |t|
90
+ tasks.map do |t|
95
91
  {
96
92
  "name" => t.name,
97
93
  "config" => t.config,
@@ -1,3 +1,3 @@
1
1
  module Kurchatov
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -1,16 +1,10 @@
1
1
  not_exists:
2
2
  - not error please
3
3
 
4
- # create sample_plugin from sample
5
- sample_plugin:
6
- cmd: 'ls'
7
- url: 'http://example.com'
8
- parent: sample
9
- sleep: 2
4
+ new_multi_start:
5
+ parent: multi_start
10
6
 
11
- # cteate sample_0 and sample_1
12
- sample:
13
- - url: 'http://google.com'
14
- cmd: 'test -f ./tests/run.sh'
15
- - url: 'https://www.kernel.org'
16
- cmd: 'ps'
7
+ multi_start:
8
+ - event_sended: false
9
+ - event_sended: false
10
+ - event_sended: true
data/tests/data/event.yml CHANGED
@@ -1,5 +1,17 @@
1
1
  events:
2
2
 
3
+ - :service: new_multi_start
4
+ :result: ok
5
+ :miss_send_from_plugin_data: true
6
+
7
+ - :service: multi_start_0
8
+ :result: ok
9
+ :miss_send_from_plugin_data: true
10
+
11
+ - :service: multi_start_1
12
+ :result: ok
13
+ :miss_send_from_plugin_data: true
14
+
3
15
  - :metric: 3
4
16
  :critical: 2
5
17
  :warning: 1
@@ -37,11 +49,6 @@ events:
37
49
  :result: warning
38
50
  :service: Shell test
39
51
 
40
- - :eval_metric: 'rest_get("http://ya.ru").size'
41
- :critical: 10
42
- :result: critical
43
- :service: Http get test
44
-
45
52
  - :eval_metric: 'rest_get("http://127.0.0.1:55755").size'
46
53
  :critical: 1
47
54
  :result: critical
@@ -1,12 +1,12 @@
1
- name "sample"
1
+ name "plugin_data"
2
2
  always_start true
3
3
 
4
4
  collect do
5
5
  data = YAML.load_file('./tests/data/event.yml')
6
6
  data["events"].each do |e|
7
+ next if e[:miss_send_from_plugin_data]
7
8
  e[:metric] = eval(e[:eval_metric]) if e.has_key? :eval_metric
8
9
  event(e)
9
10
  end
10
- sleep(plugin.sleep.to_f)
11
- exit 0 if plugin.sleep # 1 plugin send exit 0
11
+ stop!
12
12
  end
@@ -0,0 +1,14 @@
1
+ name "ignore errors with count"
2
+
3
+ # CHECK_ALIVE_TIMEOUT = 5 second
4
+ # sleep_plugin 20
5
+ # raise errors
6
+
7
+ always_start true
8
+ ignore_errors 3
9
+
10
+ collect do
11
+ @errors ||= 1
12
+ raise "error" if @errors < 3
13
+ @error += 1
14
+ end
@@ -1,7 +1,8 @@
1
- name "with error plugin"
1
+ name "ignore errors"
2
2
 
3
- ignore_errors true
4
3
  always_start true
4
+ ignore_errors true
5
+ interval 1
5
6
 
6
7
  collect do
7
8
  raise "error"
@@ -0,0 +1,11 @@
1
+ name "multi_start"
2
+ always_start true
3
+
4
+ default[:event_sended] = false
5
+
6
+ collect do
7
+ if !plugin.event_sended
8
+ event(:service => "#{name}", :state => 'ok')
9
+ end
10
+ plugin.event_sended = true
11
+ end
@@ -0,0 +1,9 @@
1
+ name "not ignore errors"
2
+
3
+ always_start true
4
+ ignore_errors false
5
+
6
+ collect do
7
+ raise "error" if (@first_start ||= true)
8
+ @first_start = false
9
+ end
@@ -0,0 +1,8 @@
1
+ name "plugin sleep"
2
+
3
+ always_start true
4
+
5
+ collect do
6
+ 20.times {|x| puts "Sleep from 'plugin sleep', count: #{x}"; sleep 1; }
7
+ exit 0
8
+ end
data/tests/run.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh -e
2
2
  bundle exec ruby ./tests/server.rb &
3
- bundle exec kurchatov -c ./tests/data/config.yml -d ./tests/data -H 127.0.0.1 --http 127.0.0.1:55755
3
+ bundle exec kurchatov -c ./tests/data/config.yml -d ./tests/data/plugins -H 127.0.0.1 --http 127.0.0.1:55755 -l debug
@@ -23,7 +23,7 @@ class TestReceived
23
23
  from_data = data["events"].select {|x| x[:miss_count] != true }.count
24
24
  from_events = @events.count
25
25
 
26
- raise "Not all events recieved: from data: #{from_data} and from server: #{from_events}" unless 3 * from_data == from_events # see config.yml (3 copy of sample plugin run)
26
+ raise "Not all events recieved: from data: #{from_data} and from server: #{from_events}" unless from_data == from_events
27
27
 
28
28
  puts "Recieved events:"
29
29
  puts "#{@events.inspect}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kurchatov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliev Dmitry
@@ -193,11 +193,14 @@ files:
193
193
  - lib/ohai/plugins/windows/platform.rb
194
194
  - tests/data/config.yml
195
195
  - tests/data/event.yml
196
- - tests/data/plugin_dont_start.rb
197
- - tests/data/plugin_sample.rb
198
- - tests/data/plugin_with_errors.rb
199
- - tests/data/plugin_with_errors_with_count.rb
200
- - tests/data/plugin_with_no_required.rb
196
+ - tests/data/plugins/plugin_data.rb
197
+ - tests/data/plugins/plugin_dont_start.rb
198
+ - tests/data/plugins/plugin_ignore_errors_with_count.rb_
199
+ - tests/data/plugins/plugin_ingore_errors.rb
200
+ - tests/data/plugins/plugin_multi_start.rb
201
+ - tests/data/plugins/plugin_not_ignore_errors.rb_
202
+ - tests/data/plugins/plugin_sleep.rb
203
+ - tests/data/plugins/plugin_with_no_required.rb
201
204
  - tests/run.sh
202
205
  - tests/server.rb
203
206
  - tests/testreceived.rb
@@ -1,8 +0,0 @@
1
- name "plugin with error count"
2
-
3
- ignore_errors 4
4
- always_start true
5
-
6
- collect do
7
- raise "error"
8
- end