resurrected_god 0.14.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +559 -0
- data/README.md +9 -4
- data/bin/god +26 -28
- data/ext/god/extconf.rb +9 -9
- data/lib/god/behavior.rb +3 -5
- data/lib/god/behaviors/clean_pid_file.rb +4 -6
- data/lib/god/behaviors/clean_unix_socket.rb +4 -6
- data/lib/god/behaviors/notify_when_flapping.rb +13 -15
- data/lib/god/cli/command.rb +109 -89
- data/lib/god/cli/run.rb +51 -75
- data/lib/god/cli/version.rb +2 -4
- data/lib/god/condition.rb +12 -14
- data/lib/god/conditions/always.rb +3 -2
- data/lib/god/conditions/complex.rb +23 -24
- data/lib/god/conditions/cpu_usage.rb +12 -16
- data/lib/god/conditions/degrading_lambda.rb +15 -19
- data/lib/god/conditions/disk_usage.rb +7 -8
- data/lib/god/conditions/file_mtime.rb +3 -7
- data/lib/god/conditions/file_touched.rb +4 -5
- data/lib/god/conditions/flapping.rb +57 -62
- data/lib/god/conditions/http_response_code.rb +27 -32
- data/lib/god/conditions/lambda.rb +3 -5
- data/lib/god/conditions/memory_usage.rb +12 -16
- data/lib/god/conditions/process_exits.rb +12 -12
- data/lib/god/conditions/process_running.rb +8 -10
- data/lib/god/conditions/socket_responding.rb +23 -28
- data/lib/god/conditions/tries.rb +12 -14
- data/lib/god/configurable.rb +7 -10
- data/lib/god/contact.rb +41 -52
- data/lib/god/contacts/airbrake.rb +10 -12
- data/lib/god/contacts/campfire.rb +18 -20
- data/lib/god/contacts/email.rb +27 -28
- data/lib/god/contacts/prowl.rb +16 -17
- data/lib/god/contacts/scout.rb +2 -5
- data/lib/god/contacts/sensu.rb +15 -11
- data/lib/god/contacts/slack.rb +23 -33
- data/lib/god/contacts/statsd.rb +8 -8
- data/lib/god/contacts/twitter.rb +2 -2
- data/lib/god/contacts/webhook.rb +21 -24
- data/lib/god/driver.rb +12 -18
- data/lib/god/errors.rb +0 -2
- data/lib/god/event_handler.rb +40 -49
- data/lib/god/event_handlers/dummy_handler.rb +1 -1
- data/lib/god/event_handlers/kqueue_handler.rb +2 -2
- data/lib/god/event_handlers/netlink_handler.rb +1 -1
- data/lib/god/logger.rb +5 -13
- data/lib/god/metric.rb +13 -15
- data/lib/god/process.rb +93 -98
- data/lib/god/simple_logger.rb +13 -15
- data/lib/god/socket.rb +21 -23
- data/lib/god/sugar.rb +8 -8
- data/lib/god/sys_logger.rb +6 -8
- data/lib/god/system/portable_poller.rb +1 -9
- data/lib/god/system/process.rb +4 -6
- data/lib/god/system/slash_proc_poller.rb +17 -19
- data/lib/god/task.rb +110 -136
- data/lib/god/timeline.rb +2 -4
- data/lib/god/trigger.rb +7 -11
- data/lib/god/version.rb +1 -1
- data/lib/god/watch.rb +51 -57
- data/lib/god.rb +122 -148
- metadata +17 -370
- data/Announce.txt +0 -135
- data/Gemfile +0 -5
- data/Rakefile +0 -129
- data/doc/god.asciidoc +0 -1592
- data/doc/intro.asciidoc +0 -20
- data/ext/god/.gitignore +0 -5
- data/lib/god/compat19.rb +0 -33
- data/lib/god/contacts/hipchat.rb +0 -117
- data/lib/god/contacts/jabber.rb +0 -75
- data/test/configs/child_events/child_events.god +0 -44
- data/test/configs/child_events/simple_server.rb +0 -3
- data/test/configs/child_polls/child_polls.god +0 -37
- data/test/configs/child_polls/simple_server.rb +0 -12
- data/test/configs/complex/complex.god +0 -59
- data/test/configs/complex/simple_server.rb +0 -3
- data/test/configs/contact/contact.god +0 -118
- data/test/configs/contact/simple_server.rb +0 -3
- data/test/configs/daemon_events/daemon_events.god +0 -37
- data/test/configs/daemon_events/simple_server.rb +0 -8
- data/test/configs/daemon_events/simple_server_stop.rb +0 -11
- data/test/configs/daemon_polls/daemon_polls.god +0 -17
- data/test/configs/daemon_polls/simple_server.rb +0 -6
- data/test/configs/degrading_lambda/degrading_lambda.god +0 -31
- data/test/configs/degrading_lambda/tcp_server.rb +0 -15
- data/test/configs/keepalive/keepalive.god +0 -9
- data/test/configs/keepalive/keepalive.rb +0 -12
- data/test/configs/lifecycle/lifecycle.god +0 -25
- data/test/configs/matias/matias.god +0 -50
- data/test/configs/real.rb +0 -59
- data/test/configs/running_load/running_load.god +0 -16
- data/test/configs/stop_options/simple_server.rb +0 -12
- data/test/configs/stop_options/stop_options.god +0 -39
- data/test/configs/stress/simple_server.rb +0 -3
- data/test/configs/stress/stress.god +0 -15
- data/test/configs/task/logs/.placeholder +0 -0
- data/test/configs/task/task.god +0 -26
- data/test/configs/test.rb +0 -61
- data/test/configs/usr1_trapper.rb +0 -10
- data/test/helper.rb +0 -172
- data/test/suite.rb +0 -6
- data/test/test_airbrake.rb +0 -14
- data/test/test_behavior.rb +0 -18
- data/test/test_campfire.rb +0 -22
- data/test/test_condition.rb +0 -52
- data/test/test_conditions_disk_usage.rb +0 -50
- data/test/test_conditions_http_response_code.rb +0 -109
- data/test/test_conditions_process_running.rb +0 -40
- data/test/test_conditions_socket_responding.rb +0 -176
- data/test/test_conditions_tries.rb +0 -67
- data/test/test_contact.rb +0 -109
- data/test/test_driver.rb +0 -26
- data/test/test_email.rb +0 -34
- data/test/test_event_handler.rb +0 -82
- data/test/test_god.rb +0 -710
- data/test/test_god_system.rb +0 -201
- data/test/test_handlers_kqueue_handler.rb +0 -16
- data/test/test_hipchat.rb +0 -23
- data/test/test_jabber.rb +0 -29
- data/test/test_logger.rb +0 -55
- data/test/test_metric.rb +0 -74
- data/test/test_process.rb +0 -263
- data/test/test_prowl.rb +0 -15
- data/test/test_registry.rb +0 -15
- data/test/test_sensu.rb +0 -11
- data/test/test_slack.rb +0 -57
- data/test/test_socket.rb +0 -34
- data/test/test_statsd.rb +0 -22
- data/test/test_sugar.rb +0 -42
- data/test/test_system_portable_poller.rb +0 -17
- data/test/test_system_process.rb +0 -30
- data/test/test_task.rb +0 -246
- data/test/test_timeline.rb +0 -37
- data/test/test_trigger.rb +0 -63
- data/test/test_watch.rb +0 -286
- data/test/test_webhook.rb +0 -22
data/lib/god/contacts/statsd.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Send a notice to statsd
|
2
4
|
#
|
3
5
|
# host - statsd host
|
@@ -7,7 +9,6 @@ require 'statsd-ruby'
|
|
7
9
|
|
8
10
|
module God
|
9
11
|
module Contacts
|
10
|
-
|
11
12
|
class Statsd < Contact
|
12
13
|
class << self
|
13
14
|
attr_accessor :host, :port
|
@@ -21,16 +22,16 @@ module God
|
|
21
22
|
valid
|
22
23
|
end
|
23
24
|
|
24
|
-
def notify(message,
|
25
|
+
def notify(message, _time, _priority, _category, hostname)
|
25
26
|
statsd = ::Statsd.new host, (port ? port.to_i : 8125) # 8125 is the default statsd port
|
26
27
|
|
27
|
-
hostname
|
28
|
-
app = message.gsub
|
28
|
+
hostname = hostname.tr('.', '_')
|
29
|
+
app = message.gsub(/([^\s]*).*/, '\1')
|
29
30
|
|
30
31
|
[
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
'cpu out of bounds',
|
33
|
+
'memory out of bounds',
|
34
|
+
'process is flapping'
|
34
35
|
].each do |event_type|
|
35
36
|
statsd.increment "god.#{event_type.gsub(/\s/, '_')}.#{hostname}.#{app}" if message.include? event_type
|
36
37
|
end
|
@@ -41,6 +42,5 @@ module God
|
|
41
42
|
applog(nil, :debug, e.backtrace.join("\n"))
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
45
|
end
|
46
46
|
end
|
data/lib/god/contacts/twitter.rb
CHANGED
@@ -35,13 +35,13 @@ module God
|
|
35
35
|
attr_accessor :consumer_token, :consumer_secret,
|
36
36
|
:access_token, :access_secret
|
37
37
|
|
38
|
-
def notify(message,
|
38
|
+
def notify(message, _time, _priority, _category, _host)
|
39
39
|
oauth = ::Twitter::OAuth.new(arg(:consumer_token), arg(:consumer_secret))
|
40
40
|
oauth.authorize_from_access(arg(:access_token), arg(:access_secret))
|
41
41
|
|
42
42
|
::Twitter::Base.new(oauth).update(message)
|
43
43
|
|
44
|
-
self.info =
|
44
|
+
self.info = 'sent twitter update'
|
45
45
|
rescue => e
|
46
46
|
applog(nil, :info, "failed to send twitter update: #{e.message}")
|
47
47
|
applog(nil, :debug, e.backtrace.join("\n"))
|
data/lib/god/contacts/webhook.rb
CHANGED
@@ -13,7 +13,6 @@ end
|
|
13
13
|
|
14
14
|
module God
|
15
15
|
module Contacts
|
16
|
-
|
17
16
|
class Webhook < Contact
|
18
17
|
class << self
|
19
18
|
attr_accessor :url, :format
|
@@ -32,43 +31,41 @@ module God
|
|
32
31
|
|
33
32
|
def notify(message, time, priority, category, host)
|
34
33
|
data = {
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
34
|
+
message: message,
|
35
|
+
time: time,
|
36
|
+
priority: priority,
|
37
|
+
category: category,
|
38
|
+
host: host
|
40
39
|
}
|
41
40
|
|
42
41
|
uri = URI.parse(arg(:url))
|
43
42
|
http = Net::HTTP.new(uri.host, uri.port)
|
44
|
-
http.use_ssl = true if uri.scheme ==
|
45
|
-
|
46
|
-
req = nil
|
47
|
-
res = nil
|
43
|
+
http.use_ssl = true if uri.scheme == 'https'
|
48
44
|
|
49
45
|
case arg(:format)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
when :form
|
47
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
48
|
+
req.set_form_data(data)
|
49
|
+
when :json
|
50
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
51
|
+
req.body = data.to_json
|
52
|
+
else
|
53
|
+
# This line is unreachable
|
54
|
+
raise 'Condition is invalid'
|
56
55
|
end
|
57
56
|
|
58
57
|
res = http.request(req)
|
59
58
|
|
60
|
-
case res
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
self.info = case res
|
60
|
+
when Net::HTTPSuccess
|
61
|
+
"sent webhook to #{arg(:url)}"
|
62
|
+
else
|
63
|
+
"failed to send webhook to #{arg(:url)}: #{res.error!}"
|
64
|
+
end
|
66
65
|
rescue Object => e
|
67
66
|
applog(nil, :info, "failed to send webhook to #{arg(:url)}: #{e.message}")
|
68
67
|
applog(nil, :debug, e.backtrace.join("\n"))
|
69
68
|
end
|
70
|
-
|
71
69
|
end
|
72
|
-
|
73
70
|
end
|
74
71
|
end
|
data/lib/god/driver.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
require 'monitor'
|
2
2
|
|
3
|
-
# Ruby 1.9.1 specific fixes.
|
4
|
-
if RUBY_VERSION.between?('1.9', '1.9.1')
|
5
|
-
require 'god/compat19'
|
6
|
-
end
|
7
|
-
|
8
3
|
module God
|
9
4
|
# The TimedEvent class represents an event in the future. This class is used
|
10
5
|
# by the drivers to schedule upcoming conditional tests and other scheduled
|
@@ -28,7 +23,7 @@ module God
|
|
28
23
|
#
|
29
24
|
# Returns true if the event is due, false if not.
|
30
25
|
def due?
|
31
|
-
Time.now >=
|
26
|
+
Time.now >= at
|
32
27
|
end
|
33
28
|
|
34
29
|
# Compare this event to another.
|
@@ -38,7 +33,7 @@ module God
|
|
38
33
|
# Returns -1 if this event is before the other, 0 if the two events are
|
39
34
|
# due at the same time, 1 if the other event is later.
|
40
35
|
def <=>(other)
|
41
|
-
|
36
|
+
at <=> other.at
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
@@ -116,7 +111,8 @@ module God
|
|
116
111
|
def pop
|
117
112
|
@monitor.synchronize do
|
118
113
|
if @events.empty?
|
119
|
-
raise ThreadError,
|
114
|
+
raise ThreadError, 'queue empty' if @shutdown
|
115
|
+
|
120
116
|
@resource.wait
|
121
117
|
else
|
122
118
|
delay = @events.first.at - Time.now
|
@@ -177,16 +173,14 @@ module God
|
|
177
173
|
|
178
174
|
@thread = Thread.new do
|
179
175
|
loop do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
applog(nil, :fatal, message)
|
189
|
-
end
|
176
|
+
@events.pop.handle_event
|
177
|
+
rescue ThreadError
|
178
|
+
# queue is empty
|
179
|
+
break
|
180
|
+
rescue Object => e
|
181
|
+
message = format("Unhandled exception in driver loop - (%{class}): %{message}\n%{backtrace}",
|
182
|
+
class: e.class, message: e.message, backtrace: e.backtrace.join("\n"))
|
183
|
+
applog(nil, :fatal, message)
|
190
184
|
end
|
191
185
|
end
|
192
186
|
end
|
data/lib/god/errors.rb
CHANGED
data/lib/god/event_handler.rb
CHANGED
@@ -13,23 +13,21 @@ module God
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.load
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
raise NotImplementedError, "Platform not supported for EventHandler"
|
26
|
-
end
|
27
|
-
@@loaded = true
|
28
|
-
rescue Exception
|
29
|
-
require 'god/event_handlers/dummy_handler'
|
30
|
-
@@handler = DummyHandler
|
31
|
-
@@loaded = false
|
16
|
+
case RUBY_PLATFORM
|
17
|
+
when /darwin/i, /bsd/i
|
18
|
+
require 'god/event_handlers/kqueue_handler'
|
19
|
+
@@handler = KQueueHandler
|
20
|
+
when /linux/i
|
21
|
+
require 'god/event_handlers/netlink_handler'
|
22
|
+
@@handler = NetlinkHandler
|
23
|
+
else
|
24
|
+
raise NotImplementedError, 'Platform not supported for EventHandler'
|
32
25
|
end
|
26
|
+
@@loaded = true
|
27
|
+
rescue Exception
|
28
|
+
require 'god/event_handlers/dummy_handler'
|
29
|
+
@@handler = DummyHandler
|
30
|
+
@@loaded = false
|
33
31
|
end
|
34
32
|
|
35
33
|
def self.register(pid, event, &block)
|
@@ -39,12 +37,12 @@ module God
|
|
39
37
|
end
|
40
38
|
|
41
39
|
def self.deregister(pid, event)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
return unless watching_pid?(pid)
|
41
|
+
|
42
|
+
running = ::Process.kill(0, pid.to_i) rescue false
|
43
|
+
@@actions[pid].delete(event)
|
44
|
+
@@handler.register_process(pid, @@actions[pid].keys) if running
|
45
|
+
@@actions.delete(pid) if @@actions[pid].empty?
|
48
46
|
end
|
49
47
|
|
50
48
|
def self.call(pid, event, extra_data = {})
|
@@ -58,55 +56,48 @@ module God
|
|
58
56
|
def self.start
|
59
57
|
@@thread = Thread.new do
|
60
58
|
loop do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
applog(nil, :fatal, message)
|
67
|
-
end
|
59
|
+
@@handler.handle_events
|
60
|
+
rescue Exception => e
|
61
|
+
message = format("Unhandled exception (%{class}): %{message}\n%{backtrace}",
|
62
|
+
class: e.class, message: e.message, backtrace: e.backtrace.join("\n"))
|
63
|
+
applog(nil, :fatal, message)
|
68
64
|
end
|
69
65
|
end
|
70
66
|
|
71
67
|
# do a real test to make sure events are working properly
|
72
|
-
@@loaded =
|
68
|
+
@@loaded = operational?
|
73
69
|
end
|
74
70
|
|
75
71
|
def self.stop
|
76
|
-
@@thread
|
72
|
+
@@thread&.kill
|
77
73
|
end
|
78
74
|
|
79
75
|
def self.operational?
|
80
76
|
com = [false]
|
81
77
|
|
82
78
|
Thread.new do
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
pid = fork do
|
87
|
-
loop { sleep(1) }
|
88
|
-
end
|
79
|
+
pid = fork do
|
80
|
+
loop { sleep(1) }
|
81
|
+
end
|
89
82
|
|
90
|
-
|
91
|
-
|
92
|
-
|
83
|
+
register(pid, :proc_exit) do
|
84
|
+
com[0] = true
|
85
|
+
end
|
93
86
|
|
94
|
-
|
95
|
-
|
87
|
+
::Process.kill('KILL', pid)
|
88
|
+
::Process.waitpid(pid)
|
96
89
|
|
97
|
-
|
90
|
+
sleep(0.1)
|
98
91
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
92
|
+
deregister(pid, :proc_exit) rescue nil
|
93
|
+
rescue => e
|
94
|
+
puts e.message
|
95
|
+
puts e.backtrace.join("\n")
|
104
96
|
end.join
|
105
97
|
|
106
98
|
sleep(0.1)
|
107
99
|
|
108
100
|
com.first
|
109
101
|
end
|
110
|
-
|
111
102
|
end
|
112
103
|
end
|
@@ -2,7 +2,7 @@ require 'kqueue_handler_ext'
|
|
2
2
|
|
3
3
|
module God
|
4
4
|
class KQueueHandler
|
5
|
-
EVENT_SYSTEM =
|
5
|
+
EVENT_SYSTEM = 'kqueue'.freeze
|
6
6
|
|
7
7
|
def self.register_process(pid, events)
|
8
8
|
monitor_process(pid, events_mask(events))
|
@@ -10,7 +10,7 @@ module God
|
|
10
10
|
|
11
11
|
def self.events_mask(events)
|
12
12
|
events.inject(0) do |mask, event|
|
13
|
-
mask
|
13
|
+
mask | event_mask(event)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/god/logger.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module God
|
2
|
-
|
3
2
|
class Logger < SimpleLogger
|
4
|
-
|
5
3
|
attr_accessor :logs
|
6
4
|
|
7
5
|
class << self
|
@@ -22,7 +20,6 @@ module God
|
|
22
20
|
@templog.level = Logger::INFO
|
23
21
|
end
|
24
22
|
|
25
|
-
|
26
23
|
def level=(lev)
|
27
24
|
SysLogger.level = SimpleLogger::CONSTANT_TO_SYMBOL[lev] if Logger.syslog
|
28
25
|
super(lev)
|
@@ -36,7 +33,7 @@ module God
|
|
36
33
|
# Returns nothing
|
37
34
|
def log(watch, level, text)
|
38
35
|
# initialize watch log if necessary
|
39
|
-
|
36
|
+
logs[watch.name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT) if watch
|
40
37
|
|
41
38
|
# push onto capture and timeline for the given watch
|
42
39
|
if @capture || (watch && (Time.now - @spool < 2))
|
@@ -50,13 +47,13 @@ module God
|
|
50
47
|
if @capture
|
51
48
|
@capture.puts(message)
|
52
49
|
else
|
53
|
-
|
50
|
+
logs[watch.name] << [Time.now, message]
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
57
54
|
|
58
55
|
# send to regular logger
|
59
|
-
|
56
|
+
send(level, text)
|
60
57
|
|
61
58
|
# send to syslog
|
62
59
|
SysLogger.log(level, text) if Logger.syslog
|
@@ -69,16 +66,12 @@ module God
|
|
69
66
|
# Returns String
|
70
67
|
def watch_log_since(watch_name, since)
|
71
68
|
# initialize watch log if necessary
|
72
|
-
|
69
|
+
logs[watch_name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT)
|
73
70
|
|
74
71
|
# get and join lines since given time
|
75
72
|
@mutex.synchronize do
|
76
73
|
@spool = Time.now
|
77
|
-
|
78
|
-
x.first > since
|
79
|
-
end.map do |x|
|
80
|
-
x[1]
|
81
|
-
end.join
|
74
|
+
logs[watch_name].select { |x| x.first > since }.map { |x| x[1] }.join
|
82
75
|
end
|
83
76
|
end
|
84
77
|
|
@@ -105,5 +98,4 @@ module God
|
|
105
98
|
end
|
106
99
|
end
|
107
100
|
end
|
108
|
-
|
109
101
|
end
|
data/lib/god/metric.rb
CHANGED
@@ -32,7 +32,7 @@ module God
|
|
32
32
|
def condition(kind)
|
33
33
|
# Create the condition.
|
34
34
|
begin
|
35
|
-
c = Condition.generate(kind,
|
35
|
+
c = Condition.generate(kind, watch)
|
36
36
|
rescue NoSuchConditionError => e
|
37
37
|
abort e.message
|
38
38
|
end
|
@@ -44,24 +44,22 @@ module God
|
|
44
44
|
c.prepare
|
45
45
|
|
46
46
|
# Test generic and specific validity.
|
47
|
-
unless Condition.valid?(c) && c.valid?
|
48
|
-
abort "Exiting on invalid condition"
|
49
|
-
end
|
47
|
+
abort 'Exiting on invalid condition' unless Condition.valid?(c) && c.valid?
|
50
48
|
|
51
49
|
# Inherit interval from watch if no poll condition specific interval was
|
52
50
|
# set.
|
53
|
-
if c.
|
54
|
-
if
|
55
|
-
c.interval =
|
51
|
+
if c.is_a?(PollCondition) && !c.interval
|
52
|
+
if watch.interval
|
53
|
+
c.interval = watch.interval
|
56
54
|
else
|
57
|
-
abort "No interval set for Condition '#{c.class.name}' in Watch "
|
58
|
-
"'#{
|
59
|
-
|
55
|
+
abort "No interval set for Condition '#{c.class.name}' in Watch " \
|
56
|
+
"'#{watch.name}', and no default Watch interval from " \
|
57
|
+
'which to inherit.'
|
60
58
|
end
|
61
59
|
end
|
62
60
|
|
63
61
|
# Add the condition to the list.
|
64
|
-
|
62
|
+
conditions << c
|
65
63
|
end
|
66
64
|
|
67
65
|
# Enable all of this Metric's conditions. Poll conditions will be
|
@@ -69,8 +67,8 @@ module God
|
|
69
67
|
#
|
70
68
|
# Returns nothing.
|
71
69
|
def enable
|
72
|
-
|
73
|
-
|
70
|
+
conditions.each do |c|
|
71
|
+
watch.attach(c)
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
@@ -79,8 +77,8 @@ module God
|
|
79
77
|
#
|
80
78
|
# Returns nothing.
|
81
79
|
def disable
|
82
|
-
|
83
|
-
|
80
|
+
conditions.each do |c|
|
81
|
+
watch.detach(c)
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|