servicemonitor 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/servicemonitor +1 -0
- data/lib/MonitorManager.rb +27 -17
- data/lib/MonitorType/Beanstalk.rb +30 -0
- data/lib/MonitorType/FluidDb.rb +1 -1
- data/lib/MonitorType/Threshold.rb +1 -0
- metadata +2 -1
data/bin/servicemonitor
CHANGED
data/lib/MonitorManager.rb
CHANGED
@@ -1,25 +1,35 @@
|
|
1
1
|
|
2
2
|
class MonitorManager
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
def initialize
|
4
|
+
@list = Array.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def add( monitor )
|
8
|
+
@list.push monitor
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
12
|
while true do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
@list.each do |m|
|
14
|
+
begin
|
15
|
+
m.sanitise
|
16
|
+
m.run
|
17
17
|
rescue MonitorTypeExceptionHandled => e
|
18
|
-
|
19
|
-
end
|
18
|
+
m.alert( e.message )
|
20
19
|
end
|
21
|
-
|
20
|
+
end
|
21
|
+
sleep 0.5
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
|
+
rescue Interrupt => e
|
25
|
+
puts "Exiting on request ..."
|
26
|
+
|
27
|
+
rescue Exception => e
|
28
|
+
puts e.class.name
|
29
|
+
puts "*** This is really unexpected."
|
30
|
+
messageLoop = false
|
31
|
+
puts "Message: " + e.message
|
32
|
+
puts e.backtrace
|
33
|
+
end
|
24
34
|
end
|
25
35
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "beanstalk-client"
|
2
|
+
require "MonitorType/Threshold"
|
3
|
+
|
4
|
+
class MonitorType_Beanstalk<MonitorType_Threshold
|
5
|
+
|
6
|
+
def sanitise
|
7
|
+
@beanstalk = Beanstalk::Pool.new([@connection_string])
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize( name, queue, params )
|
11
|
+
super( name, params )
|
12
|
+
@connection_string = params[:beanstalk] || "localhost:11300"
|
13
|
+
@queue = queue
|
14
|
+
self.sanitise
|
15
|
+
rescue MonitorTypeExceptionHandled => e
|
16
|
+
puts e.message
|
17
|
+
abort()
|
18
|
+
end
|
19
|
+
|
20
|
+
def process
|
21
|
+
tubeStats = @beanstalk.stats_tube(@queue)
|
22
|
+
|
23
|
+
self.check( tubeStats["current-jobs-ready"], "Checking number of jobs in queue, #{@queue}" )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def beanstalk( name, queue, params )
|
28
|
+
$a.add( MonitorType_Beanstalk.new( name, queue, params ) )
|
29
|
+
end
|
30
|
+
|
data/lib/MonitorType/FluidDb.rb
CHANGED
@@ -20,7 +20,7 @@ class MonitorType_FluidDb<MonitorType_Threshold
|
|
20
20
|
def process
|
21
21
|
value = @fluidDb.queryForValue( @sql, [] )
|
22
22
|
|
23
|
-
self.check( value
|
23
|
+
self.check( value, "Checking result of sql query, #{@sql}" )
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- lib/Alert/Email.rb
|
22
22
|
- lib/Alert.rb
|
23
23
|
- lib/MonitorManager.rb
|
24
|
+
- lib/MonitorType/Beanstalk.rb
|
24
25
|
- lib/MonitorType/Dir.rb
|
25
26
|
- lib/MonitorType/FluidDb.rb
|
26
27
|
- lib/MonitorType/Threshold.rb
|