sensu-plugin 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sensu-handler.rb +7 -9
- data/lib/sensu-plugin.rb +1 -1
- data/test/handle_filter_test.rb +12 -0
- metadata +4 -4
data/lib/sensu-handler.rb
CHANGED
@@ -68,15 +68,13 @@ module Sensu
|
|
68
68
|
occurrences = @event['check']['occurrences'] || 1
|
69
69
|
interval = @event['check']['interval'] || 30
|
70
70
|
refresh = @event['check']['refresh'] || 1800
|
71
|
-
if @event['
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
bail 'only handling every ' + number.to_s + ' occurrences'
|
79
|
-
end
|
71
|
+
if @event['occurrences'] < occurrences
|
72
|
+
bail 'not enough occurrences'
|
73
|
+
end
|
74
|
+
if @event['occurrences'] > occurrences && @event['action'] == 'create'
|
75
|
+
number = refresh.fdiv(interval).to_i
|
76
|
+
unless number == 0 || @event['occurrences'] % number == 0
|
77
|
+
bail 'only handling every ' + number.to_s + ' occurrences'
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end
|
data/lib/sensu-plugin.rb
CHANGED
data/test/handle_filter_test.rb
CHANGED
@@ -42,6 +42,18 @@ class TestFilterExternal < MiniTest::Unit::TestCase
|
|
42
42
|
}
|
43
43
|
output = run_script_with_input(JSON.generate(event))
|
44
44
|
assert_equal(0, $?.exitstatus)
|
45
|
+
assert_match(/^not enough occurrences/, output)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_resolve_enough_occurrences
|
49
|
+
event = {
|
50
|
+
'client' => { 'name' => 'test' },
|
51
|
+
'check' => { 'name' => 'test', 'occurrences' => 2 },
|
52
|
+
'occurrences' => 2,
|
53
|
+
'action' => 'resolve'
|
54
|
+
}
|
55
|
+
output = run_script_with_input(JSON.generate(event))
|
56
|
+
assert_equal(0, $?.exitstatus)
|
45
57
|
assert_match(/^Event:/, output)
|
46
58
|
end
|
47
59
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Decklin Foster
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-10-01 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|