Sha256: bd6bf3b1db537f4ad265e8d3db2b0d2c184e794ff9d610208aaed34495a15c66
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'net/ping/tcp' require 'outpost/expectations' module Outpost module Scouts # Uses net/ping tcp pinger to check if port is open # # * Responds to response_time expectation # ({Outpost::Expectations::ResponseTime}) class Tcp < Ping extend Outpost::Expectations::ResponseTime attr_reader :response_time report_data :response_time # Configure the scout with given options. # @param [Hash] Options to setup the scout # @option options [String] :host The host that will be "pinged". # @option options [Object] :pinger An object that can ping hosts. # Defaults to Net::Ping::Tcp.new def setup(options) host = options[:host] port = options[:port] timeout= options[:timeout] || 3 pinger = options[:pinger] || Net::Ping::TCP @pinger = pinger.new(host, port, timeout) end # Runs the scout, pinging the host and getting the duration. def execute if @pinger.ping? # Miliseconds @response_time = @pinger.duration * 1000 end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
outpost-0.2.5 | lib/outpost/scouts/tcp.rb |
outpost-0.2.4 | lib/outpost/scouts/tcp.rb |