riemann-babbler 1.2.0 → 1.2.1
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.
|
@@ -2,13 +2,20 @@ class Riemann::Babbler::Runit < Riemann::Babbler
|
|
|
2
2
|
|
|
3
3
|
def init
|
|
4
4
|
plugin.set_default(:service, 'runit')
|
|
5
|
-
plugin.set_default(:not_monit, [])
|
|
5
|
+
plugin.set_default(:not_monit, ['riemann-client'])
|
|
6
|
+
plugin.set_default(:warning_uptime, 10)
|
|
6
7
|
plugin.set_default(:interval, 60)
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
def run_plugin
|
|
10
11
|
Dir.exists? '/etc/service'
|
|
11
|
-
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# service uptime
|
|
15
|
+
def uptime(service)
|
|
16
|
+
pid_file = File.join(service, 'supervise', 'pid')
|
|
17
|
+
return 0 unless File.exist?(pid_file)
|
|
18
|
+
Time.now.to_i - File.mtime(pid_file).to_i
|
|
12
19
|
end
|
|
13
20
|
|
|
14
21
|
def read_run_status
|
|
@@ -18,14 +25,13 @@ class Riemann::Babbler::Runit < Riemann::Babbler
|
|
|
18
25
|
human_srv = ' ' + srv.gsub(/\/etc\/service\//, '')
|
|
19
26
|
stat_file = File.join(srv, 'supervise', 'stat')
|
|
20
27
|
next unless File.exists? stat_file
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
status << {:service => plugin.service + human_srv , :state => 'ok', :description => "runit service #{human_srv} running"}
|
|
28
|
+
srv_uptime = uptime(srv)
|
|
29
|
+
if (File.read( stat_file ).strip == 'run') && (srv_uptime > plugin.interval)
|
|
30
|
+
status << {:service => plugin.service + human_srv , :state => 'ok', :description => "runit service #{human_srv} running", :metric => srv_uptime}
|
|
31
|
+
elsif (File.read( stat_file ).strip == 'run') && (srv_uptime < plugin.warning_uptime)
|
|
32
|
+
status << {:service => plugin.service + human_srv , :state => 'warning', :description => "runit service #{human_srv} small uptime", :metric => srv_uptime}
|
|
24
33
|
else
|
|
25
|
-
|
|
26
|
-
status << {:service => plugin.service + human_srv , :state => 'critical', :description => "runit service #{human_srv} not running"}
|
|
27
|
-
end
|
|
28
|
-
@status_history << human_srv unless @status_history.include? human_srv
|
|
34
|
+
status << {:service => plugin.service + human_srv , :state => 'critical', :description => "runit service #{human_srv} not running", :metric => srv_uptime}
|
|
29
35
|
end
|
|
30
36
|
end
|
|
31
37
|
status
|
|
@@ -3,24 +3,20 @@ require 'json'
|
|
|
3
3
|
|
|
4
4
|
class Riemann::Responder
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
{
|
|
6
|
+
INFO = {
|
|
8
7
|
:version => Riemann::Babbler::VERSION,
|
|
9
|
-
:ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}"
|
|
10
|
-
|
|
11
|
-
}.to_json
|
|
12
|
-
end
|
|
8
|
+
:ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}"
|
|
9
|
+
}.freeze
|
|
13
10
|
|
|
14
11
|
def initialize( port = 55755 )
|
|
15
12
|
@port = port
|
|
16
|
-
@started_at = Time.now.to_i
|
|
17
13
|
end
|
|
18
14
|
|
|
19
15
|
def start
|
|
20
16
|
@worker_thread = Thread.new {
|
|
21
17
|
Socket.tcp_server_loop(@port) do |sock, _|
|
|
22
18
|
begin
|
|
23
|
-
sock.puts
|
|
19
|
+
sock.puts INFO.to_json
|
|
24
20
|
ensure
|
|
25
21
|
sock.close
|
|
26
22
|
end
|
|
@@ -34,5 +30,4 @@ class Riemann::Responder
|
|
|
34
30
|
@worker_thread = nil
|
|
35
31
|
end
|
|
36
32
|
end
|
|
37
|
-
|
|
38
33
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: riemann-babbler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-08-
|
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: riemann-client
|
|
@@ -194,8 +194,8 @@ files:
|
|
|
194
194
|
- lib/riemann/babbler/start.rb
|
|
195
195
|
- lib/riemann/babbler/support/deep_merge.rb
|
|
196
196
|
- lib/riemann/babbler/support/monkey_patches.rb
|
|
197
|
+
- lib/riemann/babbler/support/pinger.rb
|
|
197
198
|
- lib/riemann/babbler/support/plugin_helpers.rb
|
|
198
|
-
- lib/riemann/babbler/support/responder.rb
|
|
199
199
|
- lib/riemann/babbler/version.rb
|
|
200
200
|
- riemann-babbler.gemspec
|
|
201
201
|
- spec/config.yml
|