kurchatov 0.0.6.pre.4 → 0.0.6.pre.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: c2c33704a13c283abff889703ea874cdbf649063
4
- data.tar.gz: d072ed418b07f26a742aba939ffc78f38f9630cf
3
+ metadata.gz: 870ee3524e61a543f0239a9bc5d5e635b228e964
4
+ data.tar.gz: 29c5ea749c45fea4391af9845ac57e112cb59bfa
5
5
  SHA512:
6
- metadata.gz: 0a94cec105593e4e8422f02aaaef444c0d9cf1adc40fe65b599b3f6a6f52dcbe68242f50026bcbccedbde3915ee8ef1830e1244b56e364e1056c4a97f0f80f37
7
- data.tar.gz: 63b221f779d9184ce083e80b457cb30e260ba2003014899b2c50a634c562d4dd8dbaf05df9e7a8bce1acf84c927bf01acb51525568deb113f3109a28111a6f08
6
+ metadata.gz: 1ae6eb277c085226329af0d2014042e0eae58447c1c0da53bb518236c19092a5d25a2368ee2d2a24bec892ff3cc67d485c1f106ee06076a23d119a25ef07caab
7
+ data.tar.gz: 42af4c91a332ed6f1d99c1673578ff031b714e19b56f77fd13e35205d47240d6d7dfc784044bcbf7e2179f5834ce54fcad0526747b7eeb3b6849cf2ef3b618d4
data/CHANGELOG CHANGED
@@ -2,3 +2,4 @@
2
2
  * Version 0.0.6.pre.1: Add ignore errors
3
3
  * Version 0.0.6.pre.2: :metric => boolean return integer
4
4
  * Version 0.0.6.pre.4: Required block for plugin
5
+ * Version 0.0.6.pre.5: Improve http responder, add monitor
@@ -14,6 +14,7 @@ module Kurchatov
14
14
  class Application
15
15
  include Mixlib::CLI
16
16
  include Kurchatov::Mixin::Ohai
17
+ include Kurchatov::Mixin::Monitor
17
18
 
18
19
  option :help,
19
20
  :short => '-h',
@@ -119,24 +120,24 @@ module Kurchatov
119
120
  return if Config[:test_plugin]
120
121
  Log.error('Please set riemann host') and exit Config[:ERROR_CONFIG] unless Config[:riemann_responder]
121
122
  if Config[:udp_responder]
122
- @monitor << Responders::Udp.new(Config[:udp_responder])
123
+ monitor << Responders::Udp.new(Config[:udp_responder])
123
124
  end
124
125
  if Config[:http_responder]
125
- @monitor << Responders::Http.new(Config[:http_responder])
126
+ monitor << Responders::Http.new(Config[:http_responder])
126
127
  end
127
- @monitor << Responders::Riemann.new(Config[:riemann_responder])
128
+ monitor << Responders::Riemann.new(Config[:riemann_responder])
128
129
  end
129
130
 
130
131
  def configure_plugins
131
132
  return if Config[:test_plugin]
132
133
  plugins = Kurchatov::Plugins::Config.load_plugins(Config[:plugin_paths],
133
134
  Config[:config_file])
134
- plugins.each { |p| @monitor << p }
135
+ plugins.each { |p| monitor << p }
135
136
  end
136
137
 
137
138
  def configure_test_plugin
138
139
  return unless Config[:test_plugin]
139
- @monitor << Kurchatov::Plugins::DSL.load_riemann_plugin(Config[:test_plugin])
140
+ monitor << Kurchatov::Plugins::DSL.load_riemann_plugin(Config[:test_plugin])
140
141
  end
141
142
 
142
143
  def run
@@ -147,7 +148,7 @@ module Kurchatov
147
148
  configure_responders
148
149
  configure_plugins
149
150
  configure_test_plugin
150
- @monitor.run
151
+ monitor.run
151
152
  end
152
153
 
153
154
  end
@@ -3,3 +3,4 @@ require_relative 'http'
3
3
  require_relative 'ohai'
4
4
  require_relative 'queue'
5
5
  require_relative 'event'
6
+ require_relative 'monitor'
@@ -0,0 +1,18 @@
1
+ require 'kurchatov/monitor'
2
+
3
+ module Kurchatov
4
+ module Mixin
5
+ module Monitor
6
+
7
+ class << self
8
+ attr_accessor :instance_monitor
9
+ end
10
+
11
+ def monitor
12
+ @instance_monitor ||= Kurchatov::Mixin::Monitor.instance_monitor ||=
13
+ Kurchatov::Monitor.new(Kurchatov::Config[:stop_on_error] || !!Kurchatov::Config[:test_plugin])
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -4,7 +4,7 @@ module Kurchatov
4
4
  module Mixin
5
5
  module Queue
6
6
 
7
- class << self;
7
+ class << self
8
8
  attr_accessor :instance_queue
9
9
  end
10
10
 
@@ -10,6 +10,22 @@ module Kurchatov
10
10
  @thread = Thread.new { @plugin.run }
11
11
  end
12
12
 
13
+ def status
14
+ !!@thread.alive?
15
+ end
16
+
17
+ def name
18
+ @plugin.name
19
+ end
20
+
21
+ def type
22
+ @plugin.class.to_s
23
+ end
24
+
25
+ def uptime
26
+ @plugin.uptime
27
+ end
28
+
13
29
  def died?
14
30
  return false if @thread.alive?
15
31
  # thread died, join and extract error
@@ -19,7 +35,7 @@ module Kurchatov
19
35
  desc = "Plugin '#{@plugin.name}' died. #{e.class}: #{e}\n." +
20
36
  "Trace: #{e.backtrace.join("\n")}"
21
37
  Log.error(desc)
22
- unless @plugin.ignore_errors
38
+ unless @plugin.ignore_errors
23
39
  event(:service => 'riemann client errors', :desc => desc, :state => 'critical')
24
40
  end
25
41
  end
@@ -50,8 +66,8 @@ module Kurchatov
50
66
  end
51
67
  end
52
68
 
53
- def tasks_status
54
- @tasks.map { |t| t.status }
69
+ def inspect
70
+ @tasks.map {|t| {name: t.name, alive: t.status, type: t.type, uptime: t.uptime} }
55
71
  end
56
72
 
57
73
  end
@@ -26,6 +26,7 @@ module Kurchatov
26
26
  end
27
27
 
28
28
  def run
29
+ super
29
30
  loop do
30
31
  t_start = Time.now
31
32
  Timeout::timeout(interval * 2.to_f/3) do
@@ -10,7 +10,11 @@ module Kurchatov
10
10
  end
11
11
 
12
12
  def run
13
- raise
13
+ @t_start = Time.now
14
+ end
15
+
16
+ def uptime
17
+ Time.now.to_i - @t_start.to_i
14
18
  end
15
19
 
16
20
  end
@@ -2,6 +2,8 @@ module Kurchatov
2
2
  module Responders
3
3
  class Http < Kurchatov::Plugin
4
4
 
5
+ include Kurchatov::Mixin::Monitor
6
+
5
7
  def initialize(conn)
6
8
  @host, @port = conn.split(':')
7
9
  @name = "http server #{@host}:#{@port}"
@@ -9,6 +11,7 @@ module Kurchatov
9
11
  end
10
12
 
11
13
  def run
14
+ super
12
15
  @server ||= TCPServer.new(@host, @port)
13
16
  loop do
14
17
  client = @server.accept
@@ -28,7 +31,7 @@ module Kurchatov
28
31
  {
29
32
  :version => Kurchatov::VERSION,
30
33
  :uptime => (Time.now - @s_time).to_i,
31
- :config => Kurchatov::Config.to_hash,
34
+ :monitor => monitor.inspect,
32
35
  }.to_json + "\n"
33
36
  end
34
37
 
@@ -14,6 +14,7 @@ module Kurchatov
14
14
  end
15
15
 
16
16
  def run
17
+ super
17
18
  make_clients
18
19
  loop { flush; sleep FLUSH_INTERVAL }
19
20
  end
@@ -11,6 +11,7 @@ module Kurchatov
11
11
 
12
12
 
13
13
  def run
14
+ super
14
15
  Socket.udp_server_loop(@host, @port) do |data, src|
15
16
  process(data, src)
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module Kurchatov
2
- VERSION = "0.0.6.pre.4"
2
+ VERSION = "0.0.6.pre.5"
3
3
  end
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.0.6.pre.4
4
+ version: 0.0.6.pre.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliev Dmitry
@@ -170,6 +170,7 @@ files:
170
170
  - lib/kurchatov/mixin/event.rb
171
171
  - lib/kurchatov/mixin/http.rb
172
172
  - lib/kurchatov/mixin/init.rb
173
+ - lib/kurchatov/mixin/monitor.rb
173
174
  - lib/kurchatov/mixin/ohai.rb
174
175
  - lib/kurchatov/mixin/queue.rb
175
176
  - lib/kurchatov/monitor.rb