servicemonitor 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/servicemonitor +6 -0
  2. data/lib/MonitorType.rb +18 -15
  3. metadata +1 -1
data/bin/servicemonitor CHANGED
@@ -11,6 +11,11 @@ require "MonitorType/Threshold"
11
11
  require "MonitorType/Dir"
12
12
  require "MonitorManager"
13
13
 
14
+ def log( string, verbose=false )
15
+ if !ENV["VERBOSE"].nil? || verbose==false then
16
+ puts string
17
+ end
18
+ end
14
19
 
15
20
  if ARGV.length == 1 then
16
21
  dslName = ARGV[0]
@@ -21,6 +26,7 @@ end
21
26
 
22
27
  $a = MonitorManager.new
23
28
 
29
+ log "Loading dsl, #{dslName}"
24
30
  load dslName
25
31
 
26
32
  $a.run
data/lib/MonitorType.rb CHANGED
@@ -7,11 +7,13 @@ class MonitorType
7
7
 
8
8
  def initialize( name, params )
9
9
  @name = name
10
- @email = params[:email]
11
-
12
- cron_string = params[:cron] || "0 1 * * *"
10
+ @email = params[:email]
11
+
12
+ cron_string = params[:cron] || "0 1 * * *"
13
13
  @cron = CronParser.new(cron_string)
14
- @next = Time.now - 1
14
+ @next = Time.now - 1
15
+
16
+ log "Loaded Monitor, #{@name}."
15
17
  end
16
18
 
17
19
  #Overload this method if any parameters should be checked
@@ -23,21 +25,22 @@ class MonitorType
23
25
  end
24
26
 
25
27
  def run
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
28
+ if Time.now > @next then
29
+ begin
30
+ @next = @cron.next( Time.now )
31
+ log "Monitor, #{@name}, next run time, #{@next}"
32
+ self.sanitise
33
+ self.process
34
+ rescue MonitorTypeExceptionHandled => e
35
+ m.alert( e.message )
36
+ end
34
37
  end
35
38
  end
36
-
37
-
39
+
40
+
38
41
  def alert( string )
39
42
  body = "#{@name} tripped.\n#{string}"
40
-
43
+ puts "*** "
41
44
  if !@email.nil? then
42
45
  Alert_Email.new( @email, body ).Send
43
46
  puts "Emailed, @email, Body, #{body}"
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: