sensu 0.9.9.beta.3 → 0.9.9.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sensu/constants.rb +1 -1
- data/lib/sensu/sandbox.rb +11 -0
- data/lib/sensu/server.rb +22 -1
- data/lib/sensu/utilities.rb +0 -14
- metadata +5 -4
data/lib/sensu/constants.rb
CHANGED
data/lib/sensu/server.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'base')
|
2
2
|
require File.join(File.dirname(__FILE__), 'redis')
|
3
3
|
require File.join(File.dirname(__FILE__), 'socket')
|
4
|
+
require File.join(File.dirname(__FILE__), 'sandbox')
|
4
5
|
|
5
6
|
module Sensu
|
6
7
|
class Server
|
@@ -121,10 +122,30 @@ module Sensu
|
|
121
122
|
subdue && subdue_at == (check[:subdue][:at] || 'handler').to_sym
|
122
123
|
end
|
123
124
|
|
125
|
+
def filter_attributes_match?(hash_one, hash_two)
|
126
|
+
hash_one.keys.all? do |key|
|
127
|
+
case
|
128
|
+
when hash_one[key] == hash_two[key]
|
129
|
+
true
|
130
|
+
when hash_one[key].is_a?(Hash) && hash_two[key].is_a?(Hash)
|
131
|
+
filter_attributes_match?(hash_one[key], hash_two[key])
|
132
|
+
when hash_one[key].is_a?(String) && hash_one[key].start_with?('eval: ')
|
133
|
+
begin
|
134
|
+
expression = hash_one[key].gsub(/^eval:(\s+)?/, '')
|
135
|
+
!!Sandbox.eval(expression, hash_two[key])
|
136
|
+
rescue
|
137
|
+
false
|
138
|
+
end
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
124
145
|
def event_filtered?(filter_name, event)
|
125
146
|
if @settings.filter_exists?(filter_name)
|
126
147
|
filter = @settings[:filters][filter_name]
|
127
|
-
matched =
|
148
|
+
matched = filter_attributes_match?(filter[:attributes], event)
|
128
149
|
filter[:negate] ? matched : !matched
|
129
150
|
else
|
130
151
|
@logger.error('unknown filter', {
|
data/lib/sensu/utilities.rb
CHANGED
@@ -57,19 +57,5 @@ module Sensu
|
|
57
57
|
diff
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
|
-
def hash_values_equal?(hash_one, hash_two)
|
62
|
-
hash_one.keys.all? do |key|
|
63
|
-
if hash_one[key] == hash_two[key]
|
64
|
-
true
|
65
|
-
else
|
66
|
-
if hash_one[key].is_a?(Hash) && hash_two[key].is_a?(Hash)
|
67
|
-
hash_values_equal?(hash_one[key], hash_two[key])
|
68
|
-
else
|
69
|
-
false
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
60
|
end
|
75
61
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1725596175
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 9
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.9.9.beta.
|
11
|
+
- 4
|
12
|
+
version: 0.9.9.beta.4
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Sean Porter
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2013-01-
|
21
|
+
date: 2013-01-13 00:00:00 -08:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/sensu/socket.rb
|
193
193
|
- lib/sensu/constants.rb
|
194
194
|
- lib/sensu/api.rb
|
195
|
+
- lib/sensu/sandbox.rb
|
195
196
|
- lib/sensu/settings.rb
|
196
197
|
- lib/sensu/redis.rb
|
197
198
|
- lib/sensu/server.rb
|