sensu-plugins-http-boutetnico 1.0.1 → 1.1.0
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/README.md +1 -0
- data/bin/metrics-curl-json.rb +83 -0
- data/lib/sensu-plugins-http/version.rb +2 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f6360dc0aca83dde1940b01531dd6c5f03a35b3
|
4
|
+
data.tar.gz: d510ec56b7512341206e734ab97a01d079ebaa32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68623e4e6a7a6528cd21b7650d1a69cc81331325d5f8a8afb88fd5a9e6f7f112f1a17abe8bf3be0fa55f27327844510fc84052c1930b16c83e4325c662c147ae
|
7
|
+
data.tar.gz: 76fe6e697ff95b89c2187d5f81a5c7186e9846145a26c36bb6466b9b277afee11af4bbc6a86fc34310e21b9c371142374ba9ee42e29b24f5916ed61c068de656
|
data/README.md
CHANGED
@@ -35,6 +35,7 @@ The Sensu assets packaged from this repository are built against the Sensu ruby
|
|
35
35
|
* bin/check-https-cert.rb
|
36
36
|
* bin/check-last-modified.rb
|
37
37
|
* bin/metrics-curl.rb
|
38
|
+
* bin/metrics-curl-json.rb
|
38
39
|
* bin/metrics-http-json-deep.rb
|
39
40
|
* bin/metrics-http-json.rb
|
40
41
|
* bin/metrics-libcurl.rb
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-curl-json
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Simple wrapper around curl for querying a JSON endpoint and return metrics.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# metric data
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: oj
|
17
|
+
# gem: socket
|
18
|
+
#
|
19
|
+
# USAGE:
|
20
|
+
# #YELLOW
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2020 Nicolas Boutet
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'socket'
|
31
|
+
require 'English'
|
32
|
+
require 'sensu-plugin/metric/cli'
|
33
|
+
require 'oj'
|
34
|
+
|
35
|
+
#
|
36
|
+
# Curl Metrics
|
37
|
+
#
|
38
|
+
class CurlMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
39
|
+
option :url,
|
40
|
+
short: '-u URL',
|
41
|
+
long: '--url URL',
|
42
|
+
description: 'valid cUrl url to connect',
|
43
|
+
default: 'http://127.0.0.1:80/'
|
44
|
+
|
45
|
+
option :curl_args,
|
46
|
+
short: '-a "CURL ARGS"',
|
47
|
+
long: '--curl_args "CURL ARGS"',
|
48
|
+
description: 'Additional arguments to pass to curl',
|
49
|
+
default: ''
|
50
|
+
|
51
|
+
option :scheme,
|
52
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
53
|
+
short: '-s SCHEME',
|
54
|
+
long: '--scheme SCHEME',
|
55
|
+
required: true,
|
56
|
+
default: Socket.gethostname.to_s
|
57
|
+
|
58
|
+
def deep_value(hash, scheme = '')
|
59
|
+
hash.each do |key, value|
|
60
|
+
if value.is_a?(Hash)
|
61
|
+
deep_value(value, "#{scheme}.#{key}")
|
62
|
+
else
|
63
|
+
output "#{scheme}.#{key}", value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
cmd = "curl --silent #{config[:curl_args]} "
|
70
|
+
cmd += config[:url]
|
71
|
+
|
72
|
+
output = `#{cmd}`
|
73
|
+
|
74
|
+
metrics = Oj.load(output, mode: :compat)
|
75
|
+
deep_value(metrics, config[:scheme])
|
76
|
+
|
77
|
+
if $CHILD_STATUS.to_i == 0
|
78
|
+
ok
|
79
|
+
else
|
80
|
+
warning
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-http-boutetnico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
@@ -231,6 +231,7 @@ executables:
|
|
231
231
|
- metrics-http-json.rb
|
232
232
|
- check-https-cert.rb
|
233
233
|
- check-head-redirect.rb
|
234
|
+
- metrics-curl-json.rb
|
234
235
|
- check-http-json.rb
|
235
236
|
- check-http-cors.rb
|
236
237
|
- check-last-modified.rb
|
@@ -249,6 +250,7 @@ files:
|
|
249
250
|
- bin/check-http.rb
|
250
251
|
- bin/check-https-cert.rb
|
251
252
|
- bin/check-last-modified.rb
|
253
|
+
- bin/metrics-curl-json.rb
|
252
254
|
- bin/metrics-curl.rb
|
253
255
|
- bin/metrics-http-json-deep.rb
|
254
256
|
- bin/metrics-http-json.rb
|