Skip to content

Commit

Permalink
Add HTTPS support (#2)
Browse files Browse the repository at this point in the history
* add HTTPS support

* update changelog and bump version

* fix links

* add HTTPS support

* update changelog and bump version
  • Loading branch information
jbfarez authored and sstarcher committed Jul 13, 2016
1 parent 1264f17 commit 17b1e49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang

## [Unreleased]

## [0.0.4] - 2016-06-15
### Added
- now support HTTPS with the "-s" toggle

## [0.0.3] - 2015-07-14
### Changed
- updated sensu-plugin gem to 1.2.0
Expand All @@ -20,6 +24,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
### Added
- initial release

[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-uchiwa/compare/0.0.3...HEAD
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-uchiwa/compare/0.0.2...0.0.3
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-uchiwa/compare/0.0.1...0.0.2
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.4...HEAD
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.3...0.0.4
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.2...0.0.3
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-iis/compare/0.0.1...0.0.2
11 changes: 9 additions & 2 deletions bin/check-uchiwa-health.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class UchiwaHealthCheck < Sensu::Plugin::Check::CLI
description: 'Your uchiwa password',
required: false

option :https,
short: '-s',
long: '--secure',
description: 'Use HTTPS instead of HTTP',
default: false,
required: false

def json_valid?(str)
JSON.parse(str)
return true
Expand All @@ -68,11 +75,11 @@ def json_valid?(str)
end

def run
endpoint = "http://#{config[:host]}:#{config[:port]}"
endpoint = config[:https] ? "https://#{config[:host]}:#{config[:port]}" : "http://#{config[:host]}:#{config[:port]}"
url = URI.parse(endpoint)

begin
res = Net::HTTP.start(url.host, url.port) do |http|
res = Net::HTTP.start(url.host, url.port, :use_ssl => url.scheme == 'https', verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
req = Net::HTTP::Get.new('/health')
req.basic_auth config[:username], config[:password] if config[:username] && config[:password]
http.request(req)
Expand Down
2 changes: 1 addition & 1 deletion lib/sensu-plugins-uchiwa/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module SensuPluginsUchiwa
module Version
MAJOR = 0
MINOR = 0
PATCH = 3
PATCH = 4

VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
end
Expand Down

0 comments on commit 17b1e49

Please sign in to comment.