Class: Outpost::Scouts::Ping
- Inherits:
-
Outpost::Scout
- Object
- Outpost::Scout
- Outpost::Scouts::Ping
- 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.
-
Responds to response_time expectation (Expectations::ResponseTime)
It needs the ‘net-ping’ gem.
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.
21 22 23 |
# File 'lib/outpost/scouts/ping.rb', line 21 def response_time @response_time end |
Instance Method Details
#execute ⇒ Object
Runs the scout, pinging the host and getting the duration.
35 36 37 38 39 40 |
# File 'lib/outpost/scouts/ping.rb', line 35 def execute if @pinger.ping(@host) # Miliseconds @response_time = @pinger.duration * 1000 end end |
#setup(options) ⇒ Object
Configure the scout with given options.
29 30 31 32 |
# File 'lib/outpost/scouts/ping.rb', line 29 def setup() @host = [:host] @pinger = [:pinger] || Net::Ping::External.new end |