riemann-babbler 1.0.8.1 → 1.0.8.2
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/Gemfile +1 -1
- data/Gemfile.lock +4 -2
- data/lib/riemann/babbler.rb +1 -1
- data/lib/riemann/babbler/plugins/status_file.rb +3 -2
- data/lib/riemann/babbler/support/plugin_helpers.rb +19 -0
- data/lib/riemann/babbler/version.rb +1 -1
- data/riemann-babbler.gemspec +1 -1
- metadata +3 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,6 +8,8 @@ GEM
|
|
8
8
|
yamler (>= 0.1.0)
|
9
9
|
diff-lcs (1.2.2)
|
10
10
|
ffi (1.4.0)
|
11
|
+
file-tail (1.0.12)
|
12
|
+
tins (~> 0.5)
|
11
13
|
logger (1.2.8)
|
12
14
|
method_source (0.8.1)
|
13
15
|
mime-types (1.21)
|
@@ -33,10 +35,10 @@ GEM
|
|
33
35
|
rspec-expectations (2.13.0)
|
34
36
|
diff-lcs (>= 1.1.3, < 2.0)
|
35
37
|
rspec-mocks (2.13.0)
|
36
|
-
sequel (3.46.0)
|
37
38
|
slop (3.4.3)
|
38
39
|
sys-filesystem (1.1.0)
|
39
40
|
ffi
|
41
|
+
tins (0.8.0)
|
40
42
|
trollop (2.0)
|
41
43
|
yamler (0.1.0)
|
42
44
|
|
@@ -46,6 +48,7 @@ PLATFORMS
|
|
46
48
|
DEPENDENCIES
|
47
49
|
awesome_print
|
48
50
|
configatron
|
51
|
+
file-tail
|
49
52
|
logger
|
50
53
|
net-ping
|
51
54
|
pry
|
@@ -53,6 +56,5 @@ DEPENDENCIES
|
|
53
56
|
rest-client
|
54
57
|
riemann-client
|
55
58
|
rspec
|
56
|
-
sequel
|
57
59
|
sys-filesystem
|
58
60
|
trollop
|
data/lib/riemann/babbler.rb
CHANGED
@@ -5,13 +5,14 @@ class Riemann::Babbler::StatusFile < Riemann::Babbler
|
|
5
5
|
plugin.states.set_default(:critical, 1)
|
6
6
|
plugin.set_default(:file, '/var/tmp/error.txt')
|
7
7
|
plugin.set_default(:interval, 60)
|
8
|
-
plugin.set_default(:
|
8
|
+
plugin.set_default(:max_lines, 100)
|
9
|
+
plugin.set_default(:report_lines, 5)
|
9
10
|
end
|
10
11
|
|
11
12
|
def collect
|
12
13
|
content = File.read(plugin.file).split("\n").delete_if {|x| x.strip.empty? }
|
13
14
|
{
|
14
|
-
:service => plugin.service + "
|
15
|
+
:service => plugin.service + " #{plugin.file}",
|
15
16
|
:description => content.last(plugin.lines).join("\n"),
|
16
17
|
:metric => content.count
|
17
18
|
}
|
@@ -43,6 +43,25 @@ module Riemann
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def file_grep(filename, regexp, max_lines=100)
|
47
|
+
readed_lines = 0
|
48
|
+
lines = Array.new
|
49
|
+
begin
|
50
|
+
Timeout::timeout(plugin_timeout) do
|
51
|
+
File::Tail::Logfile.open(file, :backward => 0) do |log|
|
52
|
+
log.tail do |line|
|
53
|
+
readed_lines += 1
|
54
|
+
lines << line if line.match?(regexp)
|
55
|
+
return lines if readed_lines >= max_lines
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
rescue => e
|
60
|
+
helper_error("#{e.class} #{e}\n#{e.backtrace.join "\n"}")
|
61
|
+
end
|
62
|
+
return lines
|
63
|
+
end
|
64
|
+
|
46
65
|
def tcp_port_aviable?(ip, port)
|
47
66
|
begin
|
48
67
|
Timeout::timeout(plugin_timeout) do
|
data/riemann-babbler.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency('sys-filesystem')
|
19
19
|
s.add_dependency('rest-client')
|
20
20
|
s.add_dependency('net-ping')
|
21
|
-
s.add_dependency('
|
21
|
+
s.add_dependency('file-tail')
|
22
22
|
|
23
23
|
s.files = `git ls-files`.split("\n")
|
24
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
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.8.
|
4
|
+
version: 1.0.8.2
|
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-07-
|
12
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riemann-client
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: file-tail
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|