sensu-plugins-http 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +6 -1
- data/bin/metrics-http-json.rb +99 -0
- data/lib/sensu-plugins-http/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGFlZjZlODVjOGQxY2QxZDE5MGU3ZDg2Y2EzZTIwMDA4MDc0MDE1NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDZiNWRiOWM5YjM0MWQ4MzJmMzQ5OTVlODA5MDU4NTczMTE0MzM1ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGQzZTIyNDY2Zjg1MDcxNTFhYTBjZjc1NzIyNzFjMGZiMzg1ZTYzN2YzODI5
|
10
|
+
NzBiZDBkZDAzMzFiMjc0ZjMwYWYxYmNmZDAzZWVlOTMyNWI4MTViNjUyNjdl
|
11
|
+
OWIyZTNhNDIzYTY0OTk4MWZkNmJhY2RhY2IyZjBhM2Y2MjQ1ODQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTgxOGViMTYzZmNiOTcyMGQ1MjIxMjIxZDc3NjhiYzM4OGY3Zjg4NzMwOTJj
|
14
|
+
NTYyN2FmZjQ5MWVjY2ZiMDZjYzg5OGM2MDdjMDg4NTcyMzliOWM0NTNkNmY5
|
15
|
+
YjI2OWE4NWRlMzBiNGY3NDYyMDgwOGFlMzIxMTEzYWNiNThhMWI=
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [0.4.0] - 2016-04-26
|
9
|
+
### Changed
|
10
|
+
- Rename http-json-graphite -> metrics-json-graphite
|
11
|
+
|
8
12
|
## [0.3.0] - 2016-04-08
|
9
13
|
### Added
|
10
14
|
- Add `metrics-http-json-deep` plugin that generates metrics from a JSON endpoint
|
@@ -64,7 +68,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
64
68
|
### Added
|
65
69
|
- Initial release
|
66
70
|
|
67
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/0.
|
71
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/0.4.0...HEAD
|
72
|
+
[0.4.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/0.3.0...0.4.0
|
68
73
|
[0.3.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/0.2.1...0.3.0
|
69
74
|
[0.2.1]: https://github.com/sensu-plugins/sensu-plugins-http/compare/0.2.0...0.2.1
|
70
75
|
[0.2.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/0.1.1...0.2.0
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# metrics-http-json.rb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Hits an HTTP endpoint which emits JSON and pushes data into Graphite.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# Graphite formatted data
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: rest-client
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# EX: ./metrics-http-json.rb -u 'http://127.0.0.1:8080/jolokia/read/com\
|
20
|
+
# .mchange.v2.c3p0:name=datasource,type=PooledDataSource' -s hostname.c3p0\
|
21
|
+
# -m 'Connections::numConnections,BusyConnections::numBusyConnections'\
|
22
|
+
# -o 'value'
|
23
|
+
#
|
24
|
+
# NOTES:
|
25
|
+
# The metric option is a comma separated list of the metric (how it will
|
26
|
+
# appear in Graphite) and the JSON key which holds the value you want to
|
27
|
+
# graph. The object option is optional and is the name of the JSON object
|
28
|
+
# which holds the key/value pairs you want to graph.
|
29
|
+
#
|
30
|
+
# LICENSE:
|
31
|
+
# phamby@gmail.com
|
32
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
33
|
+
# for details.
|
34
|
+
#
|
35
|
+
|
36
|
+
require 'sensu-plugin/metric/cli'
|
37
|
+
require 'rest-client'
|
38
|
+
require 'socket'
|
39
|
+
require 'json'
|
40
|
+
require 'uri'
|
41
|
+
#
|
42
|
+
# HttpJsonGraphite - see description above
|
43
|
+
#
|
44
|
+
class HttpJsonGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
45
|
+
option :url,
|
46
|
+
description: 'Full URL to the endpoint',
|
47
|
+
short: '-u URL',
|
48
|
+
long: '--url URL',
|
49
|
+
default: 'http://localhost:8080'
|
50
|
+
|
51
|
+
option :scheme,
|
52
|
+
description: 'Metric naming scheme',
|
53
|
+
short: '-s SCHEME',
|
54
|
+
long: '--scheme SCHEME',
|
55
|
+
default: Socket.gethostname.to_s
|
56
|
+
|
57
|
+
option :metric,
|
58
|
+
description: 'Metric/JSON key pair ex:Connections::numConnections',
|
59
|
+
short: '-m METRIC::JSONKEY',
|
60
|
+
long: '--metric METRIC::JSONKEY'
|
61
|
+
|
62
|
+
option :object,
|
63
|
+
description: 'The JSON object containing the data',
|
64
|
+
short: '-o OBJECT',
|
65
|
+
long: '--object OBJECT'
|
66
|
+
|
67
|
+
def run
|
68
|
+
scheme = config[:scheme].to_s
|
69
|
+
metric_pair_input = config[:metric].to_s
|
70
|
+
if config[:object]
|
71
|
+
object = config[:object].to_s
|
72
|
+
end
|
73
|
+
url = URI.encode(config[:url].to_s)
|
74
|
+
begin
|
75
|
+
r = RestClient.get url
|
76
|
+
metric_pair_array = metric_pair_input.split(/,/)
|
77
|
+
metric_pair_array.each do |m|
|
78
|
+
metric, attribute = m.to_s.split(/::/)
|
79
|
+
unless object.nil?
|
80
|
+
JSON.parse(r)[object].each do |k, v|
|
81
|
+
if k == attribute
|
82
|
+
output([scheme, metric].join('.'), v)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
JSON.parse(r).each do |k, v|
|
86
|
+
if k == attribute
|
87
|
+
output([scheme, metric].join('.'), v)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
rescue Errno::ECONNREFUSED
|
93
|
+
critical "#{config[:url]} is not responding"
|
94
|
+
rescue RestClient::RequestTimeout
|
95
|
+
critical "#{config[:url]} Connection timed out"
|
96
|
+
end
|
97
|
+
ok
|
98
|
+
end
|
99
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -217,6 +217,7 @@ executables:
|
|
217
217
|
- metrics-curl.rb
|
218
218
|
- check-last-modified.rb
|
219
219
|
- check-https-cert.rb
|
220
|
+
- metrics-http-json.rb
|
220
221
|
- check-http.rb
|
221
222
|
extensions: []
|
222
223
|
extra_rdoc_files: []
|
@@ -230,6 +231,7 @@ files:
|
|
230
231
|
- bin/check-last-modified.rb
|
231
232
|
- bin/metrics-curl.rb
|
232
233
|
- bin/metrics-http-json-deep.rb
|
234
|
+
- bin/metrics-http-json.rb
|
233
235
|
- lib/sensu-plugins-http.rb
|
234
236
|
- lib/sensu-plugins-http/version.rb
|
235
237
|
homepage: https://github.com/sensu-plugins/sensu-plugins-http
|