olgen-god 0.9.0 → 0.9.1

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 0
4
4
  :minor: 9
@@ -3,21 +3,27 @@ module God
3
3
 
4
4
  module ConditionHelper
5
5
 
6
+ # check the result in the timeline..
6
7
  def timeline_test(res)
8
+ self.trigger_on = true if self.trigger_on.nil?
7
9
  @timeline << res
8
- history = " - SUCCESS RATE: [#{@timeline.select { |x| x }.size}/#{@timeline.length}]"
9
- if @timeline.select { |x| x }.size >= self.times[0]
10
- self.info = " PASSED #{history}"
10
+ history = " - TRIGGER RATE: [#{@timeline.select { |x| x==self.trigger_on }.size}/#{@timeline.length}]"
11
+ if @timeline.select { |x| x == self.trigger_on }.size >= self.times[0]
12
+ status = trigger_on ? "UP" : "DOWN"
13
+ self.info = " SERVICE STATUS moved to: #{status}"
11
14
  return true
12
- elsif @timeline.select { |x| !x }.size > self.times[1] - self.times[0]
13
- self.info = " FAILED #{history}"
14
- return false
15
15
  else
16
- self.info = "history too short: #{history}"
17
- return nil # do not trigger a transition
16
+ self.info = " PASSED #{history}"
17
+ return false
18
18
  end
19
19
  end
20
20
 
21
+
22
+ # # invert the result if needed...
23
+ # def trigger_check(res)
24
+ # trigger_on ? res : !res
25
+ # end
26
+
21
27
  end
22
28
  end
23
29
  end
@@ -73,7 +73,8 @@ module God
73
73
  :path, # e.g. '/'
74
74
  :headers, # e.g. {'Host' => 'myvirtual.mydomain.com'}
75
75
  :method, # e.g. :post, :get
76
- :data # e.g. {:ua=>"Mozilla 3.5"}
76
+ :data, # e.g. {:ua=>"Mozilla 3.5"}
77
+ :trigger_on # can trigger both on: true or false
77
78
 
78
79
  def initialize
79
80
  super
@@ -3,13 +3,14 @@ module God
3
3
 
4
4
  class Lambda < PollCondition
5
5
  include ConditionHelper
6
- attr_accessor :lambda, :times
6
+ attr_accessor :lambda, :times,:trigger_on # can trigger both on: true or false
7
7
 
8
8
  def initialize
9
9
  super
10
+ self.trigger_on = true
10
11
  self.times = [1, 1]
11
12
  end
12
-
13
+
13
14
  def prepare
14
15
  if self.times.kind_of?(Integer)
15
16
  self.times = [self.times, self.times]
@@ -17,6 +18,10 @@ module God
17
18
  @timeline = Timeline.new(self.times[1])
18
19
  end
19
20
 
21
+ def reset
22
+ @timeline.clear
23
+ end
24
+
20
25
  def valid?
21
26
  valid = true
22
27
  valid &= complain("Attribute 'lambda' must be specified", self) if self.lambda.nil?
@@ -26,7 +31,6 @@ module God
26
31
  def test
27
32
  return timeline_test(self.lambda.call)
28
33
  end
29
-
30
34
  end
31
35
 
32
36
  end
@@ -2,13 +2,22 @@ module God
2
2
  module Conditions
3
3
 
4
4
  class Ping < PollCondition
5
- attr_accessor :timeout, :host, :trigger_on
5
+ include ConditionHelper
6
+ attr_accessor :timeout, :host, :trigger_on, :times
6
7
 
7
8
  def initialize
8
9
  super
9
10
  self.timeout = 2 # s
10
11
  self.host = nil
11
12
  self.trigger_on=true
13
+ self.times = [1, 1]
14
+ end
15
+
16
+ def prepare
17
+ if self.times.kind_of?(Integer)
18
+ self.times = [self.times, self.times]
19
+ end
20
+ @timeline = Timeline.new(self.times[1])
12
21
  end
13
22
 
14
23
  def valid?
@@ -23,10 +32,10 @@ module God
23
32
  ping_result = `#{cmd}`
24
33
  if ping_result=~/time=/
25
34
  self.info = "Server reachable via ping!"
26
- return self.trigger_on
35
+ return timeline_test(self.trigger_on)
27
36
  end
28
37
  self.info = "Server unreachable via ping!!!"
29
- return !self.trigger_on
38
+ return timeline_test(!self.trigger_on)
30
39
  end
31
40
  end
32
41
  end
data/olgen-god.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{olgen-god}
8
- s.version = "0.9.0"
8
+ s.version = "0.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Preston-Werner, Eugen Martin"]
12
- s.date = %q{2010-02-22}
12
+ s.date = %q{2010-03-04}
13
13
  s.default_executable = %q{god}
14
14
  s.description = %q{Fork of God - God is an easy to configure, easy to extend monitoring framework written in Ruby.}
15
15
  s.email = %q{eugen.martin@madvertise.de}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 0
9
- version: 0.9.0
8
+ - 1
9
+ version: 0.9.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tom Preston-Werner, Eugen Martin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-22 00:00:00 +01:00
17
+ date: 2010-03-04 00:00:00 +01:00
18
18
  default_executable: god
19
19
  dependencies: []
20
20