riemann-babbler 1.0.7.9 → 1.0.8
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.
- data/bin/riemann-babbler +4 -3
- data/lib/riemann/{babbler/plugin.rb → babbler.rb} +9 -5
- data/lib/riemann/babbler/plugins/cpufan.rb +2 -2
- data/lib/riemann/babbler/plugins/cputemp.rb +2 -2
- data/lib/riemann/babbler/plugins/exim4.rb +1 -1
- data/lib/riemann/babbler/plugins/mdadm.rb +2 -2
- data/lib/riemann/babbler/plugins/megacli.rb +1 -1
- data/lib/riemann/babbler/plugins/netstat.rb +1 -1
- data/lib/riemann/babbler/plugins/nginx.rb +3 -11
- data/lib/riemann/babbler/plugins/runit.rb +2 -2
- data/lib/riemann/babbler/plugins/statusfile.rb +1 -1
- data/lib/riemann/babbler/plugins/twcli.rb +2 -2
- data/lib/{start.rb → riemann/babbler/start.rb} +4 -4
- data/lib/riemann/babbler/support/monkey_patches.rb +3 -3
- data/lib/riemann/babbler/support/plugin_helpers.rb +2 -1
- data/lib/riemann/{version.rb → babbler/version.rb} +1 -1
- data/riemann-babbler.gemspec +3 -3
- data/spec/default.rb +2 -2
- metadata +6 -6
data/bin/riemann-babbler
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# coding: utf-8
|
3
3
|
|
4
4
|
require 'trollop'
|
5
5
|
require 'configatron'
|
6
6
|
|
7
|
-
|
8
|
-
require
|
7
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
+
require 'riemann/babbler/version'
|
9
|
+
require 'riemann/babbler/start'
|
9
10
|
|
10
11
|
opts = Trollop::options do
|
11
12
|
version "Riemann babbler #{Riemann::Babbler::VERSION}"
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'riemann/babbler/support/plugin_helpers'
|
4
4
|
require 'riemann/client'
|
5
5
|
require 'open3'
|
6
6
|
require 'timeout'
|
@@ -8,7 +8,7 @@ require 'rest_client'
|
|
8
8
|
require 'socket'
|
9
9
|
require 'net/ping'
|
10
10
|
require 'sequel'
|
11
|
-
require
|
11
|
+
require 'riemann/babbler/support/monkey_patches'
|
12
12
|
|
13
13
|
|
14
14
|
# Базовое описание плагина
|
@@ -64,7 +64,11 @@ module Riemann
|
|
64
64
|
|
65
65
|
def report_with_diff(event)
|
66
66
|
current_metric = event[:metric]
|
67
|
-
|
67
|
+
if @storage.has_key?(event[:service])
|
68
|
+
unless current_metric + @storage[event[:service]] > 2**64
|
69
|
+
event[:metric] = current_metric - @storage[event[:service]]
|
70
|
+
end unless @storage[event[:service]].nil?
|
71
|
+
end
|
68
72
|
@storage[ event[:service] ] = current_metric
|
69
73
|
event.delete(:as_diff)
|
70
74
|
report(event)
|
@@ -96,7 +100,7 @@ module Riemann
|
|
96
100
|
if plugin.run.nil?
|
97
101
|
true
|
98
102
|
else
|
99
|
-
plugin.run
|
103
|
+
plugin.run ? true : false
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Riemann::Babbler::
|
1
|
+
class Riemann::Babbler::CpuFan < Riemann::Babbler
|
2
2
|
|
3
3
|
def init
|
4
4
|
plugin.set_default(:service, 'cpufan')
|
@@ -13,7 +13,7 @@ class Riemann::Babbler::Cpufan < Riemann::Babbler
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def collect
|
16
|
-
{ :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description =>
|
16
|
+
{ :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => 'CPU Fan Speed'}
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Riemann::Babbler::
|
1
|
+
class Riemann::Babbler::CpuTemp < Riemann::Babbler
|
2
2
|
|
3
3
|
def init
|
4
4
|
plugin.set_default(:service, 'cputemp')
|
@@ -13,7 +13,7 @@ class Riemann::Babbler::Cputemp < Riemann::Babbler
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def collect
|
16
|
-
{ :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description =>
|
16
|
+
{ :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => 'CPU Temperature'}
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -13,7 +13,7 @@ class Riemann::Babbler::Exim4 < Riemann::Babbler
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def collect
|
16
|
-
{ :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description =>
|
16
|
+
{ :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => 'Exim4: count frozen mails'}
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -14,8 +14,8 @@ class Riemann::Babbler::Mdadm < Riemann::Babbler
|
|
14
14
|
file = File.read('/proc/mdstat').split("\n")
|
15
15
|
status = Array.new
|
16
16
|
file.each_with_index do |line, index|
|
17
|
-
next unless line.include?
|
18
|
-
device = file[index-1].split(
|
17
|
+
next unless line.include? '_'
|
18
|
+
device = file[index-1].split(':')[0].strip
|
19
19
|
status << { :service => plugin.service + " #{device}", :metric => 1, :description => "mdadm failed device #{device}" }
|
20
20
|
end
|
21
21
|
status
|
@@ -12,7 +12,7 @@ class Riemann::Babbler::MegaCli < Riemann::Babbler
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def collect
|
15
|
-
{:service => plugin.service, :metric => shell(plugin.cmd).to_i, :description =>
|
15
|
+
{:service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => 'MegaCli status'}
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
@@ -1,16 +1,8 @@
|
|
1
1
|
class Riemann::Babbler::Nginx < Riemann::Babbler
|
2
2
|
|
3
|
-
NGINX_STATUS_1 =
|
4
|
-
'accepts',
|
5
|
-
'handled',
|
6
|
-
'requests'
|
7
|
-
]
|
3
|
+
NGINX_STATUS_1 = %W(accepts handled requests)
|
8
4
|
|
9
|
-
NGINX_STATUS_2 =
|
10
|
-
'reading',
|
11
|
-
'writing',
|
12
|
-
'waiting'
|
13
|
-
]
|
5
|
+
NGINX_STATUS_2 = %W(reading writing waiting)
|
14
6
|
|
15
7
|
def init
|
16
8
|
plugin.set_default(:service, 'nginx')
|
@@ -30,7 +22,7 @@ class Riemann::Babbler::Nginx < Riemann::Babbler
|
|
30
22
|
status << { :service => plugin.service + " #{NGINX_STATUS_1[index]}", :metric => value.to_i, :as_diff => true }
|
31
23
|
end
|
32
24
|
# line[0]: Active connections: XXXX
|
33
|
-
status << { :service => plugin.service +
|
25
|
+
status << { :service => plugin.service + ' active', :metric => lines[0].split(':')[1].strip.to_i }
|
34
26
|
# lines[3]: Reading: 0 Writing: 1 Waiting: 0
|
35
27
|
lines[3].scan(/\d+/).each_with_index do |value, index|
|
36
28
|
status << { :service => plugin.service + " #{NGINX_STATUS_2[index]}", :metric => value.to_i }
|
@@ -15,11 +15,11 @@ class Riemann::Babbler::Runit < Riemann::Babbler
|
|
15
15
|
status = Array.new
|
16
16
|
Dir.glob('/etc/service/*').each do |srv|
|
17
17
|
next if plugin.not_monit.include? srv
|
18
|
-
human_srv = ' ' + srv.gsub(/\/etc\/service\//,
|
18
|
+
human_srv = ' ' + srv.gsub(/\/etc\/service\//, '')
|
19
19
|
stat_file = File.join(srv, 'supervise', 'stat')
|
20
20
|
next unless File.exists? stat_file
|
21
21
|
if File.read( stat_file ).strip == 'run'
|
22
|
-
@status_history.delete
|
22
|
+
@status_history.delete 'human_srv'
|
23
23
|
status << {:service => plugin.service + human_srv , :state => 'ok', :description => "runit service #{human_srv} running"}
|
24
24
|
else
|
25
25
|
status << {:service => plugin.service + human_srv , :state => 'critical', :description => "runit service #{human_srv} not running"} if @status_history.include? human_srv
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Riemann::Babbler::
|
1
|
+
class Riemann::Babbler::TwCli < Riemann::Babbler
|
2
2
|
|
3
3
|
def init
|
4
4
|
plugin.set_default(:service, 'twcli')
|
@@ -15,7 +15,7 @@ class Riemann::Babbler::Twcli < Riemann::Babbler
|
|
15
15
|
{
|
16
16
|
:service => plugin.service,
|
17
17
|
:metric => shell(plugin.cmd).to_i,
|
18
|
-
:description =>
|
18
|
+
:description => 'Hardware raid tw_cli status'
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -2,8 +2,8 @@ require 'yaml'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'resolv'
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require 'riemann/babbler/support/deep_merge'
|
6
|
+
require 'riemann/babbler'
|
7
7
|
|
8
8
|
class Riemann::Babbler::Starter
|
9
9
|
|
@@ -37,7 +37,7 @@ class Riemann::Babbler::Starter
|
|
37
37
|
logger.warn "Can't load config file #{opts[:config]}"
|
38
38
|
Hash.new
|
39
39
|
end
|
40
|
-
config_default = YAML.load_file( File.expand_path('
|
40
|
+
config_default = YAML.load_file( File.expand_path('../../../../config.yml', __FILE__) )
|
41
41
|
config_from_file = config_default.deep_merge( config_file )
|
42
42
|
config.configure_from_hash config_from_file
|
43
43
|
end
|
@@ -61,7 +61,7 @@ class Riemann::Babbler::Starter
|
|
61
61
|
|
62
62
|
def load_plugins
|
63
63
|
plugins = Array.new
|
64
|
-
default_plugins_dir = File.expand_path('../
|
64
|
+
default_plugins_dir = File.expand_path('../plugins/', __FILE__)
|
65
65
|
Dir.glob( default_plugins_dir + '/*.rb') do |file|
|
66
66
|
plugins << file
|
67
67
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Beefcake
|
2
2
|
class Buffer
|
3
3
|
|
4
|
-
def initialize(buf=
|
4
|
+
def initialize(buf='')
|
5
5
|
if buf.respond_to?(:force_encoding)
|
6
|
-
self.buf = buf.force_encoding(
|
6
|
+
self.buf = buf.force_encoding('BINARY')
|
7
7
|
else
|
8
8
|
self.buf = buf
|
9
9
|
end
|
@@ -12,7 +12,7 @@ module Beefcake
|
|
12
12
|
def append_string(s)
|
13
13
|
append_uint64(s.length)
|
14
14
|
if s.respond_to?(:force_encoding)
|
15
|
-
self << s.force_encoding(
|
15
|
+
self << s.force_encoding('BINARY')
|
16
16
|
else
|
17
17
|
self << s
|
18
18
|
end
|
data/riemann-babbler.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/riemann/version', __FILE__)
|
2
|
+
require File.expand_path('../lib/riemann/babbler/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'riemann-babbler'
|
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.authors = ['Vasiliev D.V.']
|
8
8
|
s.email = %w(vadv.mkn@gmail.com)
|
9
9
|
s.homepage = 'https://github.com/vadv/riemann-babbler'
|
10
|
-
s.summary = %q{
|
11
|
-
s.description = %q{
|
10
|
+
s.summary = %q{Plugin manager for riemann.}
|
11
|
+
s.description = %q{Plugin manager for riemann.}
|
12
12
|
s.licenses = %w(MIT)
|
13
13
|
|
14
14
|
s.add_dependency('riemann-client')
|
data/spec/default.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -139,7 +139,7 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
-
description:
|
142
|
+
description: Plugin manager for riemann.
|
143
143
|
email:
|
144
144
|
- vadv.mkn@gmail.com
|
145
145
|
executables:
|
@@ -156,7 +156,7 @@ files:
|
|
156
156
|
- Rakefile
|
157
157
|
- bin/riemann-babbler
|
158
158
|
- config.yml
|
159
|
-
- lib/riemann/babbler
|
159
|
+
- lib/riemann/babbler.rb
|
160
160
|
- lib/riemann/babbler/plugins/cpu.rb
|
161
161
|
- lib/riemann/babbler/plugins/cpufan.rb
|
162
162
|
- lib/riemann/babbler/plugins/cputemp.rb
|
@@ -174,11 +174,11 @@ files:
|
|
174
174
|
- lib/riemann/babbler/plugins/runit.rb
|
175
175
|
- lib/riemann/babbler/plugins/statusfile.rb
|
176
176
|
- lib/riemann/babbler/plugins/twcli.rb
|
177
|
+
- lib/riemann/babbler/start.rb
|
177
178
|
- lib/riemann/babbler/support/deep_merge.rb
|
178
179
|
- lib/riemann/babbler/support/monkey_patches.rb
|
179
180
|
- lib/riemann/babbler/support/plugin_helpers.rb
|
180
|
-
- lib/riemann/version.rb
|
181
|
-
- lib/start.rb
|
181
|
+
- lib/riemann/babbler/version.rb
|
182
182
|
- riemann-babbler.gemspec
|
183
183
|
- spec/config.yml
|
184
184
|
- spec/default.rb
|
@@ -206,7 +206,7 @@ rubyforge_project:
|
|
206
206
|
rubygems_version: 1.8.23
|
207
207
|
signing_key:
|
208
208
|
specification_version: 3
|
209
|
-
summary:
|
209
|
+
summary: Plugin manager for riemann.
|
210
210
|
test_files:
|
211
211
|
- spec/config.yml
|
212
212
|
- spec/default.rb
|