Class: Outpost::Scouts::Ping

Inherits:
Outpost::Scout show all
Extended by:
Expectations::ResponseTime
Defined in:
lib/outpost/scouts/ping.rb

Overview

Uses system's “ping” command line tool to check if the server is responding in a timely manner.

Direct Known Subclasses

Tcp

Constant Summary

Constants included from Expectations::ResponseTime

Expectations::ResponseTime::RESPONSE_TIME_MAPPING

Instance Attribute Summary collapse

Attributes inherited from Outpost::Scout

#report_data

Instance Method Summary collapse

Methods included from Expectations::ResponseTime

evaluate_response_time, extended

Methods inherited from Outpost::Scout

expect, expectations, #gather_reporting_data, #initialize, report_data, #run

Constructor Details

This class inherits a constructor from Outpost::Scout

Instance Attribute Details

#response_timeObject (readonly)

Returns the value of attribute response_time


13
14
15
# File 'lib/outpost/scouts/ping.rb', line 13

def response_time
  @response_time
end

Instance Method Details

#executeObject

Runs the scout, pinging the host and getting the duration.


27
28
29
30
31
32
# File 'lib/outpost/scouts/ping.rb', line 27

def execute
  if @pinger.ping(@host)    # Miliseconds

    @response_time = @pinger.duration * 1000
  end
end

#setup(options) ⇒ Object

Configure the scout with given options.

Parameters:

  • Options (Hash)

    to setup the scout

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :host (String)

    The host that will be “pinged”.

  • :pinger (Object)

    An object that can ping hosts. Defaults to Net::Ping::External.new


21
22
23
24
# File 'lib/outpost/scouts/ping.rb', line 21

def setup(options)
  @host   = options[:host]
  @pinger = options[:pinger] || Net::Ping::External.new
end