sensu-plugins-pingmeback 0.0.3 → 0.0.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDcyODhjNDcwMDI5NTg1ZTk5OWM0OTdlOTA3MDgwYzA2MWY4MGZjNQ==
4
+ N2YwOWU0OTIwMjFjNGYyYTBhMjE1MzU0ZjcxYzFmNmE2YmQ4NDk3Zg==
5
5
  data.tar.gz: !binary |-
6
- NDEzNTM4NmMyYjExODEzOGYyMGU3ZjkzMjJkMWYxOTYwYmY4NzY1OA==
6
+ YWZlZTE0Mjc3N2Y3OWRlNTkyYzhmMzczNTk0OTFjNDhkYTgxOGM2Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2VkZTc4ZTMwZGUyZGY2ZjhhNjQyYzA2MjhmNWM4MTJmZDRhYThhOThiMTRi
10
- NWFiY2YyYmMyNDY4ODYyNmY0ZDg1MmI5OWE4MWViMjk1NjRkMWM2ZTlkMWI4
11
- MTFkZTM5OTU4MzYyM2I1NTJhZTE3ZTdmYzg5NTRlZTA2YmEyZTY=
9
+ NjQ1MWFiYmZjNjBiZmQ1YjFlOWU3MGYwZTBmZmJlNzU1NzIyMTQ3ZjEzNWY0
10
+ MWQ1ZWIwYmE3ODFjZjIyMzFmYmY4ZDE4ODZhMWM3N2I2MTkyZDI0YTU5ZmYz
11
+ NWE5MjFkNWI3YjkzNDYxMWIwYjcyOTNiYzcwZTgyNWYxZjExMTM=
12
12
  data.tar.gz: !binary |-
13
- OGVmYjUwNDgwOWQ0NjMxZDAxNjdiOWVhZDVmNzlkZThjY2YwYzJjNzIzNDFi
14
- YmRhNjViNDI1N2JiNWU3ZGNkYmM5NjhlOTk5Y2U4NTdlY2ZiMjc0YjhkMDQ4
15
- NGY3YmFkODI4YjM2N2Y1MzlkOThiMmJjODI3YTkyZTZlYWYyMDk=
13
+ Mzk3MmI4ZDM1ZDk4NzY5ODZmMDJlODYxZjkyYjliOTI3NTU3NGQ2OGZiMWM1
14
+ OGE4NjY4NzYxYjMzOWZmNWJiNDI4NjUyOTJmMGVmODA2OTQ1MzNkOGNkMDEz
15
+ OWMyYzIwZWVjNTk5ZmU2NDQwODc1NzI2YTlmZWUxZmI1OTY0NGM=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  #Change Log
2
2
 
3
+ ## 0.0.4 - 2016-03-23
4
+ - Add metrics-pingmeback.rb
5
+
3
6
  ## 0.0.3 - 2016-03-17
4
7
  - Fix net/http incompatibility with ruby 1.9.3
5
8
 
@@ -125,7 +125,7 @@ class PingmebackCheck < Sensu::Plugin::Check::CLI
125
125
  critical "Pattern \"#{config[:pattern]}\" not present in response body"
126
126
  end
127
127
  elsif k.to_s == 'message'
128
- unknown json['message']
128
+ critical json['message']
129
129
  end
130
130
  end
131
131
  else
@@ -0,0 +1,95 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # pingmeback-metrics
4
+ #
5
+ # DESCRIPTION:
6
+ # Get pingmeback metrics
7
+ # https://github.com/yanc0/sensu-plugins-pingmeback
8
+ #
9
+ # OUTPUT:
10
+ # metric data
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: uri
18
+ # gem: socket
19
+ # gem: oj
20
+ #
21
+ # USAGE:
22
+ #
23
+ # NOTES:
24
+ #
25
+ # LICENSE:
26
+ # Copyright 2016 Yann Coleu
27
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
28
+ # for details.
29
+ #
30
+
31
+ require 'sensu-plugin/metric/cli'
32
+ require 'net/http'
33
+ require 'net/https'
34
+ require 'json'
35
+ require 'uri'
36
+
37
+ #
38
+ # Pingmeback Metrics
39
+ #
40
+ class PingmebackMetrics < Sensu::Plugin::Metric::CLI::Graphite
41
+ option :host,
42
+ short: '-h HOST',
43
+ long: '--host HOST',
44
+ description: 'Your Pingmeback instance',
45
+ required: true,
46
+ default: 'http://localhost/check'
47
+
48
+ option :url,
49
+ short: '-u URL',
50
+ long: '--url URL',
51
+ description: 'Your endpoint you want to check',
52
+ required: true
53
+
54
+ option :scheme,
55
+ description: 'Metric naming scheme, text to prepend to metric',
56
+ short: '-s SCHEME',
57
+ long: '--scheme SCHEME',
58
+ default: "#{Socket.gethostname}.pingmeback"
59
+
60
+ def json_valid?(str)
61
+ JSON.parse(str)
62
+ return true
63
+ rescue JSON::ParserError
64
+ return false
65
+ end
66
+
67
+ def run
68
+ begin
69
+ uri = URI(config[:host])
70
+ req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
71
+ req.body = { url: config[:url], pattern: config[:pattern] }.to_json
72
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
73
+ http.request(req)
74
+ end
75
+
76
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,
77
+ Net::HTTPHeaderSyntaxError, Net::ProtocolError, Errno::ECONNREFUSED => e
78
+ unknown e
79
+ end
80
+
81
+ if json_valid?(res.body)
82
+ json = JSON.parse(res.body)
83
+ json.keys.each do |k|
84
+ if k.to_s == 'http_request_time'
85
+ output "#{config[:scheme]}.http_request_time", json['http_request_time']
86
+ elsif k.to_s == 'message'
87
+ critical json['message']
88
+ end
89
+ end
90
+ else
91
+ unknown 'invalid JSON'
92
+ end
93
+ ok
94
+ end
95
+ end
@@ -2,7 +2,7 @@ module SensuPluginsPingmeback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 3
5
+ PATCH = 4
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-pingmeback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-03-17 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -154,6 +154,7 @@ description: Sensu plugins for pingmeback
154
154
  email: <yann@skale-5.com>
155
155
  executables:
156
156
  - check-pingmeback.rb
157
+ - metrics-pingmeback.rb
157
158
  extensions: []
158
159
  extra_rdoc_files: []
159
160
  files:
@@ -161,6 +162,7 @@ files:
161
162
  - LICENSE
162
163
  - README.md
163
164
  - bin/check-pingmeback.rb
165
+ - bin/metrics-pingmeback.rb
164
166
  - lib/sensu-plugins-pingmeback.rb
165
167
  - lib/sensu-plugins-pingmeback/version.rb
166
168
  homepage: https://github.com/yanc0/sensu-plugins-pingmeback
@@ -192,5 +194,5 @@ rubyforge_project:
192
194
  rubygems_version: 2.4.5
193
195
  signing_key:
194
196
  specification_version: 4
195
- summary: Sensu plugins for pingmeback
197
+ summary: Ask for remote HTTP check via a pingmeback instance
196
198
  test_files: []