sensu-plugins-pingmeback 0.0.1

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTE3NzNkZTFkZDE3ODVkZmE4Yjk0NTI5MDU1YzlkNmVhNTdlNmEwMQ==
5
+ data.tar.gz: !binary |-
6
+ YmUxNzRjMjc5ZDhhN2UzYjg4NzQ3ZTE0ZGUyM2E0NzdjNmNlZTc1Mw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MWQ1YzBmY2I0ZGM2NGZmNmViMDM5OGI2OTcyMDNiNWIwYjY1OGE2OGUyMjU2
10
+ ZDBiMjUzMTEyOWU5ZDYwZWFlYjMyMWI5M2I2ZmRhMzE4ZDk2MTA3M2I3M2Fi
11
+ NDI0NDI1NGU3NWNhNWExNmFjZWU0ZTJlYTUyYmEzYzUyNDRiOTE=
12
+ data.tar.gz: !binary |-
13
+ YTIxZDIzNGJlZTZhNDZlYWU4YWI5NGI2ODFiNDZjYjFhNzYzNmIwYTgzYzEy
14
+ ZmYxYWI4NzBiOWM5MWNiZDJkNDJhYzMwYzk1NDljZTU1ODUzMmNjZTAxZTk3
15
+ YzMwYzFjMTQ4YWJlN2ZjZjI2NTZlMGNiYzA1YTY5ZGRkYWM0ZGU=
data/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.0.3] - 2015-07-14
9
+ ### Changed
10
+ - updated sensu-plugin gem to 1.2.0
11
+
12
+ ## [0.0.2] - 2015-06-03
13
+ ### Fixed
14
+ - added binstubs
15
+
16
+ ### Changed
17
+ - removed cruft from /lib
18
+
19
+ ## 0.0.1 - 2015-04-30
20
+ ### Added
21
+ - initial release
22
+
23
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.3...HEAD
24
+ [0.0.3]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.2...0.0.3
25
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.1...0.0.2
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sensu-Plugins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ ## Sensu-Plugins-pingmeback
2
+
3
+ ## Functionality
4
+
5
+ ## Files
6
+ * bin/check-pingmeback.rb
7
+
8
+ ## Usage
9
+
10
+ ## Installation
11
+
12
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
13
+
14
+ ## Notes
@@ -0,0 +1,137 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # pingmeback
4
+ #
5
+ # DESCRIPTION:
6
+ # Check HTTP health via a pingmeback instance
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: json
17
+ # gem: uri
18
+ #
19
+ # USAGE:
20
+ # #YELLOW
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Copyright 2016 Yann Coleu <y@nn-col.eu>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/check/cli'
31
+ require 'net/http'
32
+ require 'net/https'
33
+ require 'json'
34
+ require 'uri'
35
+ require 'time'
36
+
37
+ class PingmebackCheck < Sensu::Plugin::Check::CLI
38
+ option :host,
39
+ short: '-h HOST',
40
+ long: '--host HOST',
41
+ description: 'Your Pingmeback instance',
42
+ required: true,
43
+ default: 'http://localhost/check'
44
+
45
+ option :url,
46
+ short: '-u URL',
47
+ long: '--url URL',
48
+ description: 'Your endpoint you want to check',
49
+ required: true
50
+
51
+ option :pattern,
52
+ short: '-p PATTERN',
53
+ long: '--pattern PATTERN',
54
+ description: 'The string the body must contains',
55
+ required: false,
56
+ default: ''
57
+
58
+ option :response_code,
59
+ short: '-r CODE',
60
+ long: '--response_code CODE',
61
+ description: 'The expected response code',
62
+ required: false,
63
+ default: '200'
64
+
65
+ option :expiry,
66
+ short: '-e EXPIRY',
67
+ long: '--expiry EXPIRY',
68
+ description: 'Warn if cert expires within days',
69
+ required: false,
70
+ default: '30'
71
+
72
+ option :warning_time,
73
+ short: '-w WARNING',
74
+ long: '--warning WARNING',
75
+ description: 'Warn when request time is greater than time ms',
76
+ required: false,
77
+ default: '1000'
78
+
79
+ option :critical_time,
80
+ short: '-c CRITICAL',
81
+ long: '--critical CRITICAL',
82
+ description: 'Critical when request time is greater than time ms',
83
+ required: false,
84
+ default: '5000'
85
+
86
+ def json_valid?(str)
87
+ JSON.parse(str)
88
+ return true
89
+ rescue JSON::ParserError
90
+ return false
91
+ end
92
+
93
+ def run
94
+ begin
95
+ uri = URI(config[:host])
96
+ req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
97
+ req.body = { url: config[:url], pattern: config[:pattern] }.to_json
98
+ res = Net::HTTP.start(uri.hostname, uri.port) do |http|
99
+ http.request(req)
100
+ end
101
+
102
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,
103
+ Net::HTTPHeaderSyntaxError, Net::ProtocolError, Errno::ECONNREFUSED => e
104
+ unknown e
105
+ end
106
+
107
+ if json_valid?(res.body)
108
+ json = JSON.parse(res.body)
109
+ json.keys.each do |k|
110
+ if k.to_s == 'http_status_code'
111
+ if json['http_status_code'].to_s != config[:response_code]
112
+ critical "Bad status code response: #{json['http_status_code']}"
113
+ end
114
+ elsif k.to_s == 'ssl_expiry_date' && json[:ssl]
115
+ expires = ((Time.parse(json['ssl_expiry_date']) - Time.now).to_i / (24 * 60 * 60))
116
+ warning "Cert expires in #{expires} days" if expires <= config[:expiry].to_i
117
+ elsif k.to_s == 'http_request_time'
118
+ if json['http_request_time'] > config[:critical_time].to_i
119
+ critical "Request time too long: #{json['http_request_time']}ms"
120
+ elsif json['http_request_time'] > config[:warning_time].to_i
121
+ warning "Request time too long: #{json['http_request_time']}ms"
122
+ end
123
+ elsif k.to_s == 'http_body_pattern'
124
+ unless json['http_body_pattern']
125
+ critical "Pattern \"#{config[:pattern]}\" not present in response body"
126
+ end
127
+ elsif k.to_s == 'message'
128
+ unknown json['message']
129
+ end
130
+ end
131
+ else
132
+ unknown 'invalid JSON'
133
+ end
134
+
135
+ ok
136
+ end
137
+ end
@@ -0,0 +1,9 @@
1
+ module SensuPluginsPingmeback
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+
2
+ require 'sensu-plugins-pingmeback/version'
3
+
4
+ # Load the defaults
5
+
6
+ #
7
+ # Default class
8
+ #
9
+ module SensuPluginsPingmeback
10
+ class << self
11
+ end
12
+
13
+ class << self
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-pingmeback
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: github-markup
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '10.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '10.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redcarpet
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '3.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '3.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '0.37'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '0.37'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '3.4'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '3.4'
139
+ - !ruby/object:Gem::Dependency
140
+ name: yard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: '0.8'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: '0.8'
153
+ description: Sensu plugins for pingmeback
154
+ email: <yann@skale-5.com>
155
+ executables:
156
+ - check-pingmeback.rb
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - CHANGELOG.md
161
+ - LICENSE
162
+ - README.md
163
+ - bin/check-pingmeback.rb
164
+ - lib/sensu-plugins-pingmeback.rb
165
+ - lib/sensu-plugins-pingmeback/version.rb
166
+ homepage: https://github.com/yanc0/sensu-plugins-pingmeback
167
+ licenses:
168
+ - MIT
169
+ metadata:
170
+ maintainer: sensu-plugin
171
+ development_status: active
172
+ production_status: unstable - testing recommended
173
+ release_draft: 'false'
174
+ release_prerelease: 'false'
175
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
176
+ in /etc/default/sensu
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ! '>='
183
+ - !ruby/object:Gem::Version
184
+ version: 1.9.3
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubyforge_project:
192
+ rubygems_version: 2.4.5
193
+ signing_key:
194
+ specification_version: 4
195
+ summary: Sensu plugins for pingmeback
196
+ test_files: []