class NetworkMonitor

Attributes

address[RW]

Public Class Methods

new(address) click to toggle source
# File lib/load/monitors/network_monitor.rb, line 8
def initialize(address)
  @sleep_seconds = 4
  @address = address
end

Public Instance Methods

pause_after_run() click to toggle source

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

# File lib/load/monitors/network_monitor.rb, line 38
def pause_after_run
  sleep @sleep_seconds
end
run() click to toggle source
# 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() click to toggle source
# File lib/load/monitors/network_monitor.rb, line 42
def test_code
  return ("monitor.network")
end
timing() click to toggle source
# File lib/load/monitors/network_monitor.rb, line 13
def timing
  return @timing
end