Class: Outpost::Scouts::Tcp
- Inherits:
-
Ping
- Object
- Outpost::Scout
- Ping
- Outpost::Scouts::Tcp
- Extended by:
- Expectations::ResponseTime
- Defined in:
- lib/outpost/scouts/tcp.rb
Overview
Uses net/ping tcp pinger to check if port is open
-
Responds to response_time expectation (Expectations::ResponseTime)
Constant Summary
Constants included from Expectations::ResponseTime
Expectations::ResponseTime::RESPONSE_TIME_MAPPING
Instance Attribute Summary collapse
-
#response_time ⇒ Object
readonly
Returns the value of attribute response_time.
Attributes inherited from Outpost::Scout
Instance Method Summary collapse
-
#execute ⇒ Object
Runs the scout, pinging the host and getting the duration.
-
#setup(options) ⇒ Object
Configure the scout with given options.
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_time ⇒ Object (readonly)
Returns the value of attribute response_time.
12 13 14 |
# File 'lib/outpost/scouts/tcp.rb', line 12 def response_time @response_time end |
Instance Method Details
#execute ⇒ Object
Runs the scout, pinging the host and getting the duration.
30 31 32 33 34 35 |
# File 'lib/outpost/scouts/tcp.rb', line 30 def execute if @pinger.ping? # Miliseconds @response_time = @pinger.duration * 1000 end end |
#setup(options) ⇒ Object
Configure the scout with given options.
20 21 22 23 24 25 26 27 |
# File 'lib/outpost/scouts/tcp.rb', line 20 def setup() host = [:host] port = [:port] timeout= [:timeout] || 3 pinger = [:pinger] || Net::Ping::TCP @pinger = pinger.new(host, port, timeout) end |