kurchatov 0.0.6.pre.4 → 0.0.6.pre.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.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/lib/kurchatov/application.rb +7 -6
- data/lib/kurchatov/mixin/init.rb +1 -0
- data/lib/kurchatov/mixin/monitor.rb +18 -0
- data/lib/kurchatov/mixin/queue.rb +1 -1
- data/lib/kurchatov/monitor.rb +19 -3
- data/lib/kurchatov/plugin/riemann.rb +1 -0
- data/lib/kurchatov/plugin.rb +5 -1
- data/lib/kurchatov/responders/http.rb +4 -1
- data/lib/kurchatov/responders/riemann.rb +1 -0
- data/lib/kurchatov/responders/udp.rb +1 -0
- data/lib/kurchatov/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 870ee3524e61a543f0239a9bc5d5e635b228e964
|
4
|
+
data.tar.gz: 29c5ea749c45fea4391af9845ac57e112cb59bfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ae6eb277c085226329af0d2014042e0eae58447c1c0da53bb518236c19092a5d25a2368ee2d2a24bec892ff3cc67d485c1f106ee06076a23d119a25ef07caab
|
7
|
+
data.tar.gz: 42af4c91a332ed6f1d99c1673578ff031b714e19b56f77fd13e35205d47240d6d7dfc784044bcbf7e2179f5834ce54fcad0526747b7eeb3b6849cf2ef3b618d4
|
data/CHANGELOG
CHANGED
@@ -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
|
-
|
123
|
+
monitor << Responders::Udp.new(Config[:udp_responder])
|
123
124
|
end
|
124
125
|
if Config[:http_responder]
|
125
|
-
|
126
|
+
monitor << Responders::Http.new(Config[:http_responder])
|
126
127
|
end
|
127
|
-
|
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|
|
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
|
-
|
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
|
-
|
151
|
+
monitor.run
|
151
152
|
end
|
152
153
|
|
153
154
|
end
|
data/lib/kurchatov/mixin/init.rb
CHANGED
@@ -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
|
data/lib/kurchatov/monitor.rb
CHANGED
@@ -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
|
54
|
-
@tasks.map {
|
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
|
data/lib/kurchatov/plugin.rb
CHANGED
@@ -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
|
-
:
|
34
|
+
:monitor => monitor.inspect,
|
32
35
|
}.to_json + "\n"
|
33
36
|
end
|
34
37
|
|
data/lib/kurchatov/version.rb
CHANGED
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
|
+
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
|