Skip to content

Commit

Permalink
Convert numeric options to integers
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbenner authored and majormoses committed Mar 2, 2018
1 parent fcd99a4 commit 6bcd5e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Fixed
- Bug fix for `check-consul-servers` so timeout option works

## [1.6.0] - 2017-09-30
### Added
Expand Down
7 changes: 5 additions & 2 deletions bin/check-consul-servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ class ConsulStatus < Sensu::Plugin::Check::CLI
description: 'minimum number of peers',
short: '-g GREATER THAN',
long: '--greater GREATER THAN',
proc: proc(&:to_i),
default: 3

option :expected,
description: 'expected number of peers',
short: '-e EXPECT',
long: '--expect EXPECT',
proc: proc(&:to_i),
default: 5

option :scheme,
Expand All @@ -81,6 +83,7 @@ class ConsulStatus < Sensu::Plugin::Check::CLI
description: 'connection will time out after this many seconds',
short: '-t TIMEOUT_IN_SECONDS',
long: '--timeout TIMEOUT_IN_SECONDS',
proc: proc(&:to_i),
default: 5

def run
Expand All @@ -91,9 +94,9 @@ def run

json = RestClient::Resource.new(url, options).get
peers = JSON.parse(json).length.to_i
if peers < config[:min].to_i
if peers < config[:min]
critical "[#{peers}] peers is below critical threshold of [#{config[:min]}]"
elsif peers != config[:expected].to_i
elsif peers != config[:expected]
warning "[#{peers}] peers is outside of expected count of [#{config[:expected]}]"
else
ok 'Peers within threshold'
Expand Down

0 comments on commit 6bcd5e8

Please sign in to comment.