sensu-plugin 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sensu-handler.rb +5 -5
- data/lib/sensu-plugin.rb +1 -1
- data/lib/sensu-plugin/cli.rb +3 -0
- data/lib/sensu-plugin/metric/cli.rb +1 -1
- data/test/external_check_test.rb +1 -1
- data/test/external_metric_test.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f7c3f8899f53b4d8ee6bddd6c5784a8a1bfaa9a
|
4
|
+
data.tar.gz: f4602264337a31598521a7148b7ea50c2332c77a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4796d2c5b1a1bd17e718a385911c5e1b9bf578e2ef0f8076161d9d7b49cf0bc3094964ab95de5420c85936ff1bf13a834ce586b101feafd43bfb07102efe38dc
|
7
|
+
data.tar.gz: 908cd78083ecd040fc1d1a9f818536f5cbbdeb363ec4d1e4d8de1b766f81ded2740654dbfea2755584600fb0a85a4ce62d6142819389c52a8e0edb913a07d329
|
data/lib/sensu-handler.rb
CHANGED
@@ -94,17 +94,17 @@ module Sensu
|
|
94
94
|
def filter_repeated
|
95
95
|
defaults = {
|
96
96
|
'occurrences' => 1,
|
97
|
-
'interval'
|
98
|
-
'refresh'
|
97
|
+
'interval' => 30,
|
98
|
+
'refresh' => 1800
|
99
99
|
}
|
100
100
|
|
101
101
|
if settings['sensu_plugin'].is_a?(Hash)
|
102
102
|
defaults.merge!(settings['sensu_plugin'])
|
103
103
|
end
|
104
104
|
|
105
|
-
occurrences = @event['check']['occurrences'] || defaults['occurrences']
|
106
|
-
interval
|
107
|
-
refresh
|
105
|
+
occurrences = (@event['check']['occurrences'] || defaults['occurrences']).to_i
|
106
|
+
interval = (@event['check']['interval'] || defaults['interval']).to_i
|
107
|
+
refresh = (@event['check']['refresh'] || defaults['refresh']).to_i
|
108
108
|
if @event['occurrences'] < occurrences
|
109
109
|
bail 'not enough occurrences'
|
110
110
|
end
|
data/lib/sensu-plugin.rb
CHANGED
data/lib/sensu-plugin/cli.rb
CHANGED
@@ -56,6 +56,9 @@ module Sensu
|
|
56
56
|
check.run
|
57
57
|
rescue SystemExit => e
|
58
58
|
exit e.status
|
59
|
+
rescue OptionParser::InvalidOption => e
|
60
|
+
puts "Invalid check argument(s): #{e.message}, #{e.backtrace}"
|
61
|
+
exit 1
|
59
62
|
rescue Exception => e
|
60
63
|
# This can't call check.critical, as the check may have failed to construct
|
61
64
|
puts "Check failed to run: #{e.message}, #{e.backtrace}"
|
data/test/external_check_test.rb
CHANGED
@@ -49,6 +49,6 @@ class TestCheckExternal < MiniTest::Unit::TestCase
|
|
49
49
|
|
50
50
|
def test_bad_commandline
|
51
51
|
output = run_script '--doesnotexist'
|
52
|
-
assert $?.exitstatus ==
|
52
|
+
assert $?.exitstatus == 1 && output.include?('doesnotexist') && output.include?('invalid option')
|
53
53
|
end
|
54
54
|
end
|
@@ -23,7 +23,7 @@ class TestGraphiteMetricExternal < MiniTest::Unit::TestCase
|
|
23
23
|
|
24
24
|
def test_multi
|
25
25
|
lines = run_script.split("\n")
|
26
|
-
assert lines.size == 2 && lines.all? {|line| line.split("\
|
26
|
+
assert lines.size == 2 && lines.all? {|line| line.split("\s").size == 3 }
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|