Sha256: b6e8f53f94b6758c424f2001840cb8999427bb258a5c438d4546be31f9a9cb9b

Contents?: true

Size: 502 Bytes

Versions: 1

Compression:

Stored size: 502 Bytes

Contents

require 'net/ping/external'

module Outpost
  module Scouts
    class Ping < Outpost::Scout
      extend Outpost::Expectations::ResponseTime
      attr_reader :response_time

      def setup(options)
        @host = options[:host]
      end

      def execute
        # FIXME Apply Dependency Injection Principle here
        pinger = Net::Ping::External.new
        if pinger.ping(@host)
          # Miliseconds
          @response_time = pinger.duration * 100
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-0.1.0 lib/outpost/scouts/ping.rb