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.
@@ -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['action'] == 'create'
72
- if @event['occurrences'] < occurrences
73
- bail 'not enough occurrences'
74
- end
75
- if @event['occurrences'] > occurrences
76
- number = refresh.fdiv(interval).to_i
77
- unless number == 0 || @event['occurrences'] % number == 0
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
@@ -1,6 +1,6 @@
1
1
  module Sensu
2
2
  module Plugin
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  EXIT_CODES = {
5
5
  'OK' => 0,
6
6
  'WARNING' => 1,
@@ -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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
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-09-30 00:00:00 -07:00
19
+ date: 2013-10-01 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency