servicemonitor 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/MonitorManager.rb +4 -1
  2. data/lib/MonitorType.rb +16 -6
  3. metadata +2 -35
@@ -9,14 +9,17 @@ class MonitorManager
9
9
  end
10
10
 
11
11
  def run
12
+ while true do
12
13
  @list.each do |m|
13
14
  begin
14
15
  m.sanitise
15
16
  m.run
16
17
  rescue MonitorTypeExceptionHandled => e
17
- m.alert( )
18
+ m.alert( e.message )
18
19
  end
19
20
  end
21
+ sleep 0.5
22
+ end
20
23
  end
21
24
  end
22
25
 
data/lib/MonitorType.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'parse-cron'
1
2
 
2
3
  class MonitorTypeExceptionHandled<StandardError
3
4
  end
@@ -6,8 +7,12 @@ class MonitorType
6
7
 
7
8
  def initialize( name, params )
8
9
  @name = name
9
- @email = params[:email]
10
- end
10
+ @email = params[:email]
11
+
12
+ cron_string = params[:cron] || "0 1 * * *"
13
+ @cron = CronParser.new(cron_string)
14
+ @next = Time.now - 1
15
+ end
11
16
 
12
17
  #Overload this method if any parameters should be checked
13
18
  def sanitise
@@ -18,10 +23,15 @@ class MonitorType
18
23
  end
19
24
 
20
25
  def run
21
- self.sanitise
22
- self.process
23
- rescue MonitorTypeExceptionHandled => e
24
- m.alert( e.message )
26
+ if Time.now > @next then
27
+ begin
28
+ @next = @cron.next( Time.now )
29
+ self.sanitise
30
+ self.process
31
+ rescue MonitorTypeExceptionHandled => e
32
+ m.alert( e.message )
33
+ end
34
+ end
25
35
  end
26
36
 
27
37
 
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,40 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-10-25 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: parse-cron
16
- requirement: &70176457205720 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70176457205720
25
- - !ruby/object:Gem::Dependency
26
- name: beanstalk-client
27
- requirement: &70176457205260 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70176457205260
36
- - !ruby/object:Gem::Dependency
37
- name: fluiddb
38
- requirement: &70176457204800 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70176457204800
13
+ dependencies: []
47
14
  description: Monitor various parts of the system
48
15
  email: guy@guyirvine.com
49
16
  executables: