city-watch 0.5.7 → 0.5.8
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.
|
@@ -20,7 +20,7 @@ module Alerts
|
|
|
20
20
|
CityWatch.redis.zrevrange "#{CityWatch.config[:prefix]}::#{host}::#{self.name}::alerts", 0, num - 1
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def send_alerts!
|
|
23
|
+
def send_alerts!(*args)
|
|
24
24
|
get_alerts.map do |alert|
|
|
25
25
|
puts "Alert: #{alert.inspect}" if CityWatch.debug?
|
|
26
26
|
end
|
|
@@ -21,9 +21,7 @@ module Watchman
|
|
|
21
21
|
sum = dat[:summary].is_a?(Array) ? dat[:summary].inject({}) {|acc,k| acc[k.to_sym] = dat[k.to_sym]; acc} : dat[:summary]
|
|
22
22
|
CityWatch.redis.zadd "#{CityWatch.config[:prefix]}::#{host}::#{self.name}::summary", rcv_time, Yajl::Encoder.encode(sum)
|
|
23
23
|
end
|
|
24
|
-
|
|
25
|
-
run_dataset_collector(dat)
|
|
26
|
-
send_alerts!
|
|
24
|
+
run_post_processors!(dat,rcv,host)
|
|
27
25
|
return 0, sum || nil
|
|
28
26
|
end
|
|
29
27
|
|
|
@@ -53,16 +51,30 @@ module Watchman
|
|
|
53
51
|
end
|
|
54
52
|
alias_method :option, :options
|
|
55
53
|
|
|
54
|
+
def run_post_processors!(dat,rcv,host)
|
|
55
|
+
@post_processors.each do |proc|
|
|
56
|
+
proc.call(dat,rcv,host)
|
|
57
|
+
end if @post_processors
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def add_post_processor(meth=nil,&block)
|
|
61
|
+
@post_processors ||= []
|
|
62
|
+
@post_processors << (block_given? ? block : meth)
|
|
63
|
+
end
|
|
64
|
+
|
|
56
65
|
end
|
|
57
66
|
|
|
58
67
|
def self.included(base)
|
|
68
|
+
base.extend(ClassMethods)
|
|
59
69
|
base.extend(Alerts)
|
|
70
|
+
base.add_post_processor base.method(:send_alerts!)
|
|
60
71
|
base.extend(Rules)
|
|
72
|
+
base.add_post_processor base.method(:run_rules)
|
|
61
73
|
base.extend(Flags)
|
|
62
74
|
base.extend(Notifications)
|
|
63
75
|
base.extend(DataSets)
|
|
76
|
+
base.add_post_processor base.method(:run_dataset_collector)
|
|
64
77
|
base.extend(Status)
|
|
65
|
-
base.extend(ClassMethods)
|
|
66
78
|
Watchmen.register(base)
|
|
67
79
|
end
|
|
68
80
|
|
data/lib/version.rb
CHANGED