Sha256: 1ce367e518c2fd7b9948ec03fdb1e085b9fb1241530a42cf7aabe41608fd5b49
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
begin require 'net/ping/external' rescue LoadError => e puts "Please install net-ping gem: gem install net-ping". raise end require 'outpost/expectations' module Outpost module Scouts # Uses system's "ping" command line tool to check if the server is # responding in a timely manner. # # * Responds to response_time expectation # ({Outpost::Expectations::ResponseTime}) # # It needs the 'net-ping' gem. class Ping < Outpost::Scout 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::External.new def setup(options) @host = options[:host] @pinger = options[:pinger] || Net::Ping::External.new end # Runs the scout, pinging the host and getting the duration. def execute if @pinger.ping(@host) # Miliseconds @response_time = @pinger.duration * 1000 end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
outpost-0.2.3 | lib/outpost/scouts/ping.rb |
outpost-0.2.2 | lib/outpost/scouts/ping.rb |
outpost-0.2.1 | lib/outpost/scouts/ping.rb |