Class: NetworkMonitor
- Inherits:
-
TimingTest
- Object
- TimingTest
- NetworkMonitor
- Defined in:
- lib/load/monitors/network_monitor.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
Attributes inherited from TimingTest
#index, #logger, #owner, #params, #target_code
Instance Method Summary collapse
-
#initialize(address) ⇒ NetworkMonitor
constructor
A new instance of NetworkMonitor.
-
#pause_after_run ⇒ Object
64 bytes from localhost (127.0.0.1): icmp_req=4 ttl=64 time=0.015 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.018 ms.
- #run ⇒ Object
- #test_code ⇒ Object
- #timing ⇒ Object
Methods inherited from TimingTest
#assert, #ellaped_millis, #log, #server_url, #set_up, #tear_down, #time_block
Constructor Details
#initialize(address) ⇒ NetworkMonitor
Returns a new instance of NetworkMonitor.
8 9 10 11 |
# File 'lib/load/monitors/network_monitor.rb', line 8 def initialize(address) @sleep_seconds = 4 @address = address end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
6 7 8 |
# File 'lib/load/monitors/network_monitor.rb', line 6 def address @address end |
Instance Method Details
#pause_after_run ⇒ Object
64 bytes from localhost (127.0.0.1): icmp_req=4 ttl=64 time=0.015 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.018 ms
38 39 40 |
# File 'lib/load/monitors/network_monitor.rb', line 38 def pause_after_run sleep @sleep_seconds end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/load/monitors/network_monitor.rb', line 17 def run output = "" begin timing = 0 pinger = Net::Ping::External.new (1..10).each do pinger.ping(@address) timing += (pinger.duration * 1000.0) end puts "Ping timing for 10 pings: #{timing}" @timing = timing rescue Exception @timing = nil puts "Error pinging address: #{@address} => #{output}" raise "Error pinging address: #{@address} => #{output}" end end |
#test_code ⇒ Object
42 43 44 |
# File 'lib/load/monitors/network_monitor.rb', line 42 def test_code return ("monitor.network") end |
#timing ⇒ Object
13 14 15 |
# File 'lib/load/monitors/network_monitor.rb', line 13 def timing return @timing end |