kurchatov 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/Gemfile +1 -1
- data/app/Gemfile.lock +2 -2
- data/debian/changelog +6 -0
- data/lib/kurchatov/application.rb +1 -1
- data/lib/kurchatov/config.rb +2 -2
- data/lib/kurchatov/plugin/config.rb +1 -0
- data/lib/kurchatov/responders/ndjson_transport.rb +59 -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: 03637929698462ddf10999615c44bf1abbfdf764
|
4
|
+
data.tar.gz: a6b8925c35795c75e2e62d66e4da4aeef628742a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f64e8e4e28beb87c3bfac265c11d5ecb6f7d135b56f72b331bdb3f7fac7047c079bb1fabe0cadeffba103b7ae432a250897a0f79b14f1530c61167c5135d6905
|
7
|
+
data.tar.gz: b3189a467b0e43b7ec2a745366c6f53401c71513c8c8014f346750a00d42f39646a830b932edf669aaf80e48ab057a1cb32a7d1eb306b97cb4f41e0dc3420506
|
data/app/Gemfile
CHANGED
data/app/Gemfile.lock
CHANGED
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
file-tail (1.0.12)
|
15
15
|
tins (~> 0.5)
|
16
16
|
ipaddress (0.8.0)
|
17
|
-
kurchatov (0.
|
17
|
+
kurchatov (0.4.1)
|
18
18
|
beefcake (>= 0.3.5)
|
19
19
|
ohai
|
20
20
|
libyajl2 (1.0.1)
|
@@ -54,7 +54,7 @@ DEPENDENCIES
|
|
54
54
|
beefcake (= 0.5.0)
|
55
55
|
ffi-rzmq
|
56
56
|
file-tail
|
57
|
-
kurchatov (= 0.
|
57
|
+
kurchatov (= 0.4.1)
|
58
58
|
net-ntp
|
59
59
|
net-ping
|
60
60
|
parallel
|
data/debian/changelog
CHANGED
@@ -36,7 +36,7 @@ module Kurchatov
|
|
36
36
|
:short => '-l LEVEL',
|
37
37
|
:long => '--log_level LEVEL',
|
38
38
|
:description => 'Set the log level (debug, info, warn, error, fatal)',
|
39
|
-
:proc => lambda { |l| l.to_sym }
|
39
|
+
:proc => lambda { |l| l.downcase.to_sym }
|
40
40
|
|
41
41
|
option :log_location,
|
42
42
|
:short => '-L LOGLOCATION',
|
data/lib/kurchatov/config.rb
CHANGED
@@ -3,8 +3,8 @@ module Kurchatov
|
|
3
3
|
extend Mixlib::Config
|
4
4
|
default :log_level, :info
|
5
5
|
default :log_location, STDERR
|
6
|
-
default :plugin_paths, ['/usr/share/
|
7
|
-
default :config_file, '/etc/
|
6
|
+
default :plugin_paths, ['/usr/share/riemann-client/plugins']
|
7
|
+
default :config_file, '/etc/riemann-client/config.yml'
|
8
8
|
# errors
|
9
9
|
default :ERROR_CONFIG, 2
|
10
10
|
end
|
@@ -24,6 +24,7 @@ module Kurchatov
|
|
24
24
|
@all_names = Array.new
|
25
25
|
@plugins_to_run = Array.new
|
26
26
|
config = YAML.load_file(config_file)
|
27
|
+
config = {} and Log.info("Empty config file '#{config_file}'") if config == false
|
27
28
|
config.each do |name, val|
|
28
29
|
@all_names << name
|
29
30
|
next if val.nil?
|
@@ -0,0 +1,59 @@
|
|
1
|
+
name 'new line delimeter json transport'
|
2
|
+
|
3
|
+
always_start true
|
4
|
+
ignore_errors true
|
5
|
+
|
6
|
+
default[:host], default[:port] = Kurchatov::Config[:nsjson_transport].to_s.split(":")
|
7
|
+
default[:connect_timeout] = 1
|
8
|
+
default[:send_timeout] = 1
|
9
|
+
default[:exit_on_disconnect] = true
|
10
|
+
|
11
|
+
run_if do
|
12
|
+
!!plugin.host
|
13
|
+
end
|
14
|
+
|
15
|
+
helpers do
|
16
|
+
|
17
|
+
def if_error
|
18
|
+
if plugin.exit_on_disconnect
|
19
|
+
Log.error("Socket #{plugin.host}:#{plugin.port} (#{@socket.inspect}) write error, exit..")
|
20
|
+
exit 99
|
21
|
+
end
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def connect
|
26
|
+
Timeout::timeout(plugin.connect_timeout) {
|
27
|
+
@socket ||= (TCPSocket.new(plugin.host, plugin.port) rescue if_error)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def mutex
|
32
|
+
@mutex ||= Mutex.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_connection
|
36
|
+
mutex.synchronize do
|
37
|
+
yield(@socket || connect)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def flush
|
42
|
+
@events_to_send ||= events.to_flush
|
43
|
+
if !@events_to_send.empty?
|
44
|
+
@message = {"events" => @events_to_send}.to_json
|
45
|
+
Log.debug("Message: #{@message}")
|
46
|
+
with_connection do |socket|
|
47
|
+
Timeout::timeout(plugin.send_timeout) {
|
48
|
+
socket.puts(@message)
|
49
|
+
} rescue if_error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
@events_to_send = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
run do
|
58
|
+
loop { flush; sleep 1 }
|
59
|
+
end
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev Dmitry
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/kurchatov/queue.rb
|
178
178
|
- lib/kurchatov/responders/http_server.rb
|
179
179
|
- lib/kurchatov/responders/http_transport.rb
|
180
|
+
- lib/kurchatov/responders/ndjson_transport.rb
|
180
181
|
- lib/kurchatov/responders/riemann_transport.rb
|
181
182
|
- lib/kurchatov/responders/udp_server.rb
|
182
183
|
- lib/kurchatov/riemann/client.rb
|