sensu-plugins-http 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2688318fd63b4bc7b3776c42e97babce536897c
4
- data.tar.gz: e6168f39d78aabe8c5592ded921124798ff01e33
3
+ metadata.gz: 2a80fe427bc654ad938c9ef9dd0aac9485778a35
4
+ data.tar.gz: caf691caa222f28a009329a82a437dd44077d8e0
5
5
  SHA512:
6
- metadata.gz: 9d7c6302e36e1703eb97508f6793f6ffc204ca55a3ad50654f4257e5d1baaf41e484aa38a4aea529f481830ce44f3364608caee395b42035e1f53a7276e38ec2
7
- data.tar.gz: 0213ef5075fe92db8d4348dba3fc511fd0fbc0fac9bde4612d112c364d4e918df9709bd63aa96a4f2d4814052f185611908fd061ddd61184d0a8f43b655a7e4a
6
+ metadata.gz: 67c642ac68ae94fa2e5a322ba53c02f5bc6989fac0dfbfc912ebb587729a193665366270a5437afb059b4728e26c1b06b4e5a98018b0bca0b110cc8c65192f84
7
+ data.tar.gz: 09446024c1bfaeb932b4c79a72c46fffc6a11af39cb62b99e8f3d7167190c6f42623edab6ad98e2b042a3aee468cd01bc9192482dbbe59e7f887a8bf317f4be5
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [2.1.0]
8
+ ### Fixed
9
+ - `check-http-json`: fix error when check fails and --whole-response is enabled (@ushis)
10
+
11
+ ### Added
12
+ - `check-http`: add checksum check
13
+ - documentation on ssl issues (@majormoses @pgporada)
7
14
 
8
15
  ## [2.0.2] - 2017-03-13
9
16
  ### Fixed
@@ -117,7 +124,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
117
124
  ### Added
118
125
  - Initial release
119
126
 
120
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.2...HEAD
127
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.1.0...HEAD
128
+ [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.2...2.1.0
121
129
  [2.0.2]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.1...2.0.2
122
130
  [2.0.1]: https://github.com/sensu-plugins/sensu-plugins-http/compare/2.0.0...2.0.1
123
131
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-http/compare/1.0.0...2.0.0
data/README.md CHANGED
@@ -30,3 +30,6 @@ This is helpful if you do not want to configure connection information as an arg
30
30
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
31
31
 
32
32
  ## Notes
33
+
34
+ ### check-http.rb and check-https-cert.rb
35
+ This check is not really geared to check all of the complexities of ssl which is why there is a separate repo and set of checks for that: https://github.com/sensu-plugins/sensu-plugins-ssl. If you are trying to say verify cert exipiration you will notice that in some cases it does not do what you always expect it to do. For example it might appear that when using using `-k` option you see different expiration times. This is due to the fact that when using `-k` it does not check expiration of all of the certs in the chain. Rather than duplicate this behavior in this check use the other repo where we handle those more complicated ssl checks better. For more information see: https://github.com/sensu-plugins/sensu-plugins-http/issues/67
@@ -164,7 +164,7 @@ class CheckJson < Sensu::Plugin::Check::CLI
164
164
  res = http.request(req)
165
165
 
166
166
  unless res.code =~ /^2/
167
- critacal "http code: #{res.code}: body: #{res.body}" if config[:whole_response]
167
+ critical "http code: #{res.code}: body: #{res.body}" if config[:whole_response]
168
168
  critical res.code
169
169
  end
170
170
  critical 'invalid JSON from request' unless json_valid?(res.body)
data/bin/check-http.rb CHANGED
@@ -42,6 +42,7 @@
42
42
  require 'sensu-plugin/check/cli'
43
43
  require 'net/http'
44
44
  require 'net/https'
45
+ require 'digest'
45
46
 
46
47
  #
47
48
  # Check HTTP
@@ -139,6 +140,11 @@ class CheckHttp < Sensu::Plugin::Check::CLI
139
140
  long: '--negquery PAT',
140
141
  description: 'Query for a specific pattern that must be absent'
141
142
 
143
+ option :sha256checksum,
144
+ short: '-S CHECKSUM',
145
+ long: '--checksum CHECKSUM',
146
+ description: 'SHA-256 checksum'
147
+
142
148
  option :timeout,
143
149
  short: '-t SECS',
144
150
  long: '--timeout SECS',
@@ -320,6 +326,12 @@ class CheckHttp < Sensu::Plugin::Check::CLI
320
326
  else
321
327
  ok "#{res.code}, did not find /#{config[:negpattern]}/ in #{size} bytes" + body
322
328
  end
329
+ elsif config[:sha256checksum]
330
+ if Digest::SHA256.hexdigest(res.body).eql? config[:sha256checksum]
331
+ ok "#{res.code}, checksum match #{config[:sha256checksum]} in #{size} bytes" + body
332
+ else
333
+ critical "#{res.code}, checksum did not match #{config[:sha256checksum]} in #{size} bytes: #{res.body[0...200]}..."
334
+ end
323
335
  else
324
336
  ok("#{res.code}, #{size} bytes" + body) unless config[:response_code]
325
337
  end
@@ -3,8 +3,9 @@
3
3
  # check-https-cert
4
4
  #
5
5
  # DESCRIPTION:
6
- # Checks the expiration date of a URL SSL Certificate
7
- # and notifies if it is before the expiry parameter.
6
+ # Checks the expiration date of a URL's TLS/SSL Certificate
7
+ # and notifies if it is before the expiry parameter. Throws
8
+ # a critical if the date is at or past the expiry date.
8
9
  #
9
10
  # OUTPUT:
10
11
  # plain text
@@ -17,12 +18,17 @@
17
18
  # gem: net-https
18
19
  #
19
20
  # USAGE:
20
- # #YELLOW
21
+ # Check that will warn 1 week prior and critical 3 days prior
22
+ # ./check-https-cert.rb -u https://my.site.com -w 7 -c 3
23
+ #
24
+ # Check an insecure certificate that will warn 1 week prior and critical 3 days prior
25
+ # ./check-https-cert.rb -u https://my.site.com -k -w 7 -c 3
21
26
  #
22
27
  # NOTES:
23
28
  #
24
29
  # LICENSE:
25
30
  # Copyright 2014 Rhommel Lamas <roml@rhommell.com>
31
+ # Updated by Phil Porada 2017 to provide more clear documentation and messages
26
32
  # Released under the same terms as Sensu (the MIT license); see LICENSE
27
33
  # for details.
28
34
  #
@@ -38,7 +44,7 @@ class CheckHttpCert < Sensu::Plugin::Check::CLI
38
44
  short: '-u URL',
39
45
  long: '--url URL',
40
46
  proc: proc(&:to_s),
41
- description: 'A URL to connect to'
47
+ description: 'The URL to connect to'
42
48
 
43
49
  option :warning,
44
50
  short: '-w',
@@ -76,15 +82,14 @@ class CheckHttpCert < Sensu::Plugin::Check::CLI
76
82
  days_until = ((@cert.not_after - Time.now) / (60 * 60 * 24)).to_i
77
83
 
78
84
  if days_until <= 0
79
- critical "Expired #{days_until.abs} days ago."
85
+ critical "TLS/SSL certificate expired #{days_until.abs} days ago."
80
86
  elsif days_until < config[:critical].to_i
81
- critical "SSL expires on #{@cert.not_after} - #{days_until} days left."
87
+ critical "TLS/SSL certificate expires on #{@cert.not_after} - #{days_until} days left."
82
88
  elsif days_until < config[:warning].to_i
83
- warning "SSL expires on #{@cert.not_after} - #{days_until} days left."
89
+ warning "TLS/SSL certificate expires on #{@cert.not_after} - #{days_until} days left."
84
90
  else
85
- ok "SSL expires on #{@cert.not_after} - #{days_until} days left."
91
+ ok "TLS/SSL certificate expires on #{@cert.not_after} - #{days_until} days left."
86
92
  end
87
-
88
93
  rescue
89
94
  critical "Could not connect to #{config[:url]}"
90
95
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsHttp
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 0
5
- PATCH = 2
4
+ MINOR = 1
5
+ PATCH = 0
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-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.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: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin