Skip to content

Commit

Permalink
Converted timeout to numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenekjanda committed Feb 11, 2014
1 parent 75ed403 commit 32f4d3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/puppet/provider/sensu_check/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ def timeout
conf['checks'][resource[:name]]['timeout'].to_s
end

def trim num
i, f = num.to_i, num.to_f
i == f ? i : f
end

def timeout=(value)
conf['checks'][resource[:name]]['timeout'] = value.to_f
conf['checks'][resource[:name]]['timeout'] = trim(value)
end

def aggregate
Expand Down
6 changes: 3 additions & 3 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# Default: undef
#
# [*timeout*]
# Integer. Check timeout in seconds, after it fails
# Numeric. Check timeout in seconds, after it fails
# Default: undef
#
# [*aggregate*]
Expand Down Expand Up @@ -86,8 +86,8 @@
if $high_flap_threshold and !is_integer($high_flap_threshold) {
fail("sensu::check{${name}}: high_flap_threshold must be an integer (got: ${high_flap_threshold})")
}
if $timeout and !is_float($timeout) {
fail("sensu::check{${name}}: timeout must be an float (got: ${timeout})")
if $timeout and !is_numeric($timeout) {
fail("sensu::check{${name}}: timeout must be a numeric (got: ${timeout})")
}

$check_name = regsubst(regsubst($name, ' ', '_', 'G'), '[\(\)]', '', 'G')
Expand Down

0 comments on commit 32f4d3b

Please sign in to comment.