bin/check-stale-results.rb in sensu-plugins-sensu-4.1.0 vs bin/check-stale-results.rb in sensu-plugins-sensu-4.2.0

- old
+ new

@@ -43,10 +43,17 @@ short: '-c <COUNT>', long: '--crit <COUNT>', proc: proc(&:to_i), default: nil + option :timeout, + description: 'read timeout for http request', + short: '-t <TIME>', + long: '--timeout <TIME>', + proc: proc(&:to_i), + default: 60 + def initialize super raise 'Critical threshold must be higher than the warning threshold' if config[:crit] && config[:warn] >= config[:crit] @@ -76,10 +83,10 @@ either /etc/sensu/config.json or in any config that is loaded by sensu such as /etc/sensu/conf.d/api.json HEREDOC end uri = get_uri(path) - Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| + Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', read_timeout: config[:timeout]) do |http| request = net_http_req_class(method).new(path) if settings['api']['user'] && settings['api']['password'] request.basic_auth(settings['api']['user'], settings['api']['password']) end yield(request) if block_given?