servicemonitor 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/MonitorType.rb +3 -1
- data/lib/MonitorType/Beanstalk.rb +5 -2
- data/lib/MonitorType/Dir.rb +5 -3
- data/lib/MonitorType/FluidDb.rb +5 -4
- data/lib/MonitorType/Threshold.rb +24 -3
- metadata +2 -2
data/lib/MonitorType.rb
CHANGED
@@ -24,6 +24,8 @@ class MonitorType
|
|
24
24
|
puts "*** :name => <name of monitor>"
|
25
25
|
abort
|
26
26
|
end
|
27
|
+
@params = params
|
28
|
+
@block = params[:block] if !params[:block].nil?
|
27
29
|
@name = params[:name]
|
28
30
|
@email = params[:email]
|
29
31
|
if !@email.nil? then
|
@@ -75,7 +77,7 @@ class MonitorType
|
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
78
|
-
|
80
|
+
|
79
81
|
#Called when a monitor has been tripped
|
80
82
|
#
|
81
83
|
# @param [String] string A description of the trip that occurred
|
@@ -22,13 +22,16 @@ class MonitorType_Beanstalk<MonitorType_Threshold
|
|
22
22
|
abort
|
23
23
|
end
|
24
24
|
@queue = params[:queue]
|
25
|
+
|
26
|
+
@context_sentence = "Checking number of jobs in queue, #{@queue}"
|
27
|
+
|
25
28
|
self.sanitise
|
26
29
|
rescue MonitorTypeExceptionHandled => e
|
27
30
|
puts e.message
|
28
31
|
abort()
|
29
32
|
end
|
30
33
|
|
31
|
-
def
|
34
|
+
def getValue
|
32
35
|
count = 0
|
33
36
|
begin
|
34
37
|
tubeStats = @beanstalk.stats_tube(@queue)
|
@@ -36,7 +39,7 @@ class MonitorType_Beanstalk<MonitorType_Threshold
|
|
36
39
|
rescue Beanstalk::NotFoundError=>e
|
37
40
|
end
|
38
41
|
|
39
|
-
|
42
|
+
return count
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
data/lib/MonitorType/Dir.rb
CHANGED
@@ -34,15 +34,17 @@ class MonitorType_Dir<MonitorType_Threshold
|
|
34
34
|
abort
|
35
35
|
end
|
36
36
|
@path = params[:path]
|
37
|
+
|
38
|
+
@context_sentence = "Checking number of files in, #{@path}"
|
39
|
+
|
37
40
|
self.sanitise
|
38
41
|
rescue MonitorTypeExceptionHandled => e
|
39
42
|
puts e.message
|
40
43
|
abort()
|
41
44
|
end
|
42
45
|
|
43
|
-
def
|
44
|
-
|
45
|
-
self.check( number_of_files, "Checking number of files in, #{@path}" )
|
46
|
+
def getValue
|
47
|
+
return Dir.glob( "#{@path}/*" ).length
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
data/lib/MonitorType/FluidDb.rb
CHANGED
@@ -58,16 +58,17 @@ class MonitorType_FluidDb<MonitorType_Threshold
|
|
58
58
|
abort
|
59
59
|
end
|
60
60
|
@sql = params[:sql]
|
61
|
+
|
62
|
+
@context_sentence = "Checking result of sql query, #{@sql}"
|
63
|
+
|
61
64
|
self.sanitise
|
62
65
|
rescue MonitorTypeExceptionHandled => e
|
63
66
|
puts e.message
|
64
67
|
abort()
|
65
68
|
end
|
66
69
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
self.check( value, "Checking result of sql query, #{@sql}" )
|
70
|
+
def getValue
|
71
|
+
return @fluidDb.queryForValue( @sql, [] )
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -9,14 +9,35 @@ class MonitorType_Threshold<MonitorType
|
|
9
9
|
super( params )
|
10
10
|
end
|
11
11
|
|
12
|
+
#Get the context dependent value which is to be checked
|
13
|
+
def getValue
|
14
|
+
raise "Method needs to be overridden"
|
15
|
+
end
|
16
|
+
|
17
|
+
def process
|
18
|
+
if @block.nil? then
|
19
|
+
value = self.getValue
|
20
|
+
else
|
21
|
+
value = @block.call( @params )
|
22
|
+
puts "value: #{value}"
|
23
|
+
end
|
24
|
+
|
25
|
+
self.check( value )
|
26
|
+
end
|
27
|
+
|
12
28
|
#Provides the means to check a value against thresholds
|
13
|
-
def check( value
|
29
|
+
def check( value )
|
30
|
+
context_sentence = ""
|
31
|
+
if !@context_sentence.nil? then
|
32
|
+
context_sentence = "#{@context_sentence}\n"
|
33
|
+
end
|
34
|
+
|
14
35
|
value = value.to_i
|
15
36
|
if !@min.nil? && value < @min then
|
16
|
-
self.alert( "#{context_sentence}
|
37
|
+
self.alert( "#{context_sentence}Minimum threshold exceeded. Minimum: #{@min}, Actual: #{value}" )
|
17
38
|
end
|
18
39
|
if !@max.nil? && value > @max then
|
19
|
-
self.alert( "#{context_sentence}
|
40
|
+
self.alert( "#{context_sentence}Maximum threshold exceeded. Maximum: #{@max}, Actual: #{value}" )
|
20
41
|
end
|
21
42
|
|
22
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servicemonitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
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-
|
12
|
+
date: 2013-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Monitor various parts of the system
|
15
15
|
email: guy@guyirvine.com
|