Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted timeout to numeric #156

Merged
merged 1 commit into from
Feb 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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