check_graphite 0.2.3 → 0.2.4
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/README.md +1 -0
- data/lib/check_graphite.rb +12 -1
- data/lib/check_graphite/version.rb +1 -1
- data/spec/check_graphite_spec.rb +19 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 005e6702df11c50c976336ec6be597223b58ce83
|
4
|
+
data.tar.gz: 0854e7caea66b0b5a9cca85007a7161b09fcdf35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07bbf563737fc2012ce3beeaa5b096e923eae62904ec39f4cb0f6cbac2e5c4d352e2a884163370c00ab5b120bcb905b63ba7ebf0c089a6c280232e6bb25a3e20
|
7
|
+
data.tar.gz: 890ddc5b1662aa1f841c2e7c6a158be55572a8f35de36295d9b9504cda53fc1364cabcd05394ace29e8a7c567c41f82d7fc4d7fb2283bc98af71d9e8eb639840
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,7 @@ check_graphite accepts the following options:
|
|
22
22
|
* `-w`: warning threshold for the metric
|
23
23
|
* `-c`: critical threshold for the metric
|
24
24
|
* `-t`: timeout after which the metric should be considered unknown
|
25
|
+
* `--ignore-missing`: return `OK` when the metric doesn't exist yet e.g. errors have not occurred
|
25
26
|
|
26
27
|
## How it works
|
27
28
|
|
data/lib/check_graphite.rb
CHANGED
@@ -16,6 +16,9 @@ module CheckGraphite
|
|
16
16
|
on "--password PASSWORD", "-P PASSWORD"
|
17
17
|
on "--dropfirst N", "-A N", Integer, :default => 0
|
18
18
|
on "--droplast N", "-Z N", Integer, :default => 0
|
19
|
+
on "-I", "--ignore-missing", :default => false do
|
20
|
+
options.send("ignore-missing=", true)
|
21
|
+
end
|
19
22
|
|
20
23
|
enable_warning
|
21
24
|
enable_critical
|
@@ -35,7 +38,15 @@ module CheckGraphite
|
|
35
38
|
}
|
36
39
|
|
37
40
|
raise "HTTP error code #{res.code}" unless res.code == "200"
|
38
|
-
|
41
|
+
if res.body == "[]"
|
42
|
+
if options.send("ignore-missing")
|
43
|
+
store_value options.name, -1
|
44
|
+
store_message "#{options.name} missing - ignoring"
|
45
|
+
return
|
46
|
+
else
|
47
|
+
raise "no data returned for target"
|
48
|
+
end
|
49
|
+
end
|
39
50
|
|
40
51
|
datapoints = JSON(res.body).map { |e| e["datapoints"] }.reduce { |a, b| a + b }
|
41
52
|
datapoints = datapoints.slice(
|
data/spec/check_graphite_spec.rb
CHANGED
@@ -16,42 +16,42 @@ describe CheckGraphite::Command do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return OK" do
|
19
|
-
ARGV
|
19
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm })
|
20
20
|
c = CheckGraphite::Command.new
|
21
21
|
STDOUT.should_receive(:puts).with("OK: value=4.0|value=4.0;;;;")
|
22
22
|
lambda { c.run }.should raise_error SystemExit
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should return WARNING" do
|
26
|
-
ARGV
|
26
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm -w 0 })
|
27
27
|
c = CheckGraphite::Command.new
|
28
28
|
STDOUT.should_receive(:puts).with("WARNING: value=4.0|value=4.0;;;;")
|
29
29
|
lambda { c.run }.should raise_error SystemExit
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should return CRITICAL" do
|
33
|
-
ARGV
|
33
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm -c 0 })
|
34
34
|
c = CheckGraphite::Command.new
|
35
35
|
STDOUT.should_receive(:puts).with("CRITICAL: value=4.0|value=4.0;;;;")
|
36
36
|
lambda { c.run }.should raise_error SystemExit
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should honour dropfirst" do
|
40
|
-
ARGV
|
40
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm --dropfirst 1 })
|
41
41
|
c = CheckGraphite::Command.new
|
42
42
|
STDOUT.should_receive(:puts).with("OK: value=5.0|value=5.0;;;;")
|
43
43
|
lambda { c.run }.should raise_error SystemExit
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should honour droplast" do
|
47
|
-
ARGV
|
47
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm --droplast 1 })
|
48
48
|
c = CheckGraphite::Command.new
|
49
49
|
STDOUT.should_receive(:puts).with("OK: value=3.0|value=3.0;;;;")
|
50
50
|
lambda { c.run }.should raise_error SystemExit
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should honour dropfirst and droplast together" do
|
54
|
-
ARGV
|
54
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm --dropfirst 1 --droplast 1 })
|
55
55
|
c = CheckGraphite::Command.new
|
56
56
|
STDOUT.should_receive(:puts).with("OK: value=4.0|value=4.0;;;;")
|
57
57
|
lambda { c.run }.should raise_error SystemExit
|
@@ -66,7 +66,7 @@ describe CheckGraphite::Command do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should discard them" do
|
69
|
-
ARGV
|
69
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm })
|
70
70
|
c = CheckGraphite::Command.new
|
71
71
|
STDOUT.should_receive(:puts).with("OK: value=2.0|value=2.0;;;;")
|
72
72
|
lambda { c.run }.should raise_error SystemExit
|
@@ -81,11 +81,18 @@ describe CheckGraphite::Command do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should be unknown" do
|
84
|
-
ARGV
|
84
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M value.does.not.exist })
|
85
85
|
c = CheckGraphite::Command.new
|
86
86
|
STDOUT.should_receive(:puts).with(/UNKNOWN: INTERNAL ERROR: (RuntimeError: )?no data returned for target/)
|
87
87
|
lambda { c.run }.should raise_error SystemExit
|
88
88
|
end
|
89
|
+
|
90
|
+
it "should be ok when ignoring missing data" do
|
91
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M value.does.not.exist --ignore-missing })
|
92
|
+
c = CheckGraphite::Command.new
|
93
|
+
STDOUT.should_receive(:puts).with(/OK: value missing - ignoring/)
|
94
|
+
lambda { c.run }.should raise_error SystemExit
|
95
|
+
end
|
89
96
|
end
|
90
97
|
|
91
98
|
describe "when Graphite returns only NULL values" do
|
@@ -96,7 +103,7 @@ describe CheckGraphite::Command do
|
|
96
103
|
end
|
97
104
|
|
98
105
|
it "should be unknown" do
|
99
|
-
ARGV
|
106
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M all.values.null })
|
100
107
|
c = CheckGraphite::Command.new
|
101
108
|
STDOUT.should_receive(:puts).with(/UNKNOWN: INTERNAL ERROR: (RuntimeError: )?no valid datapoints/)
|
102
109
|
lambda { c.run }.should raise_error SystemExit
|
@@ -111,7 +118,7 @@ describe CheckGraphite::Command do
|
|
111
118
|
end
|
112
119
|
|
113
120
|
it "should return OK" do
|
114
|
-
ARGV
|
121
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox*.load.load.midterm })
|
115
122
|
c = CheckGraphite::Command.new
|
116
123
|
STDOUT.should_receive(:puts).with("OK: value=4.0|value=4.0;;;;")
|
117
124
|
lambda { c.run }.should raise_error SystemExit
|
@@ -129,14 +136,14 @@ describe CheckGraphite::Command do
|
|
129
136
|
end
|
130
137
|
|
131
138
|
it "should work with valid username and password" do
|
132
|
-
ARGV
|
139
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm -U testuser -P testpass})
|
133
140
|
c = CheckGraphite::Command.new
|
134
141
|
STDOUT.should_receive(:puts).with("OK: value=2.0|value=2.0;;;;")
|
135
142
|
lambda { c.run }.should raise_error SystemExit
|
136
143
|
end
|
137
144
|
|
138
145
|
it "should fail with bad username and password" do
|
139
|
-
ARGV
|
146
|
+
stub_const("ARGV", %w{ -H http://your.graphite.host/render -M collectd.somebox.load.load.midterm -U baduser -P badpass })
|
140
147
|
c = CheckGraphite::Command.new
|
141
148
|
STDOUT.should_receive(:puts).with(/UNKNOWN: INTERNAL ERROR: (RuntimeError: )?HTTP error code 401/)
|
142
149
|
lambda { c.run }.should raise_error SystemExit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Yves Ritschard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nagios_check
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project: check_graphite
|
106
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.4.5
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: check_graphite
|