Class: ZombieCheck::Ping::UnixPing

Inherits:
PingSender show all
Defined in:
lib/zombie_check/ping/ping_sender/unix_ping.rb

Instance Attribute Summary

Attributes inherited from PingSender

#duration, #host

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ UnixPing

Returns a new instance of UnixPing.



5
6
7
# File 'lib/zombie_check/ping/ping_sender/unix_ping.rb', line 5

def initialize(host)
  super host
end

Instance Method Details

#sendObject



9
10
11
12
13
# File 'lib/zombie_check/ping/ping_sender/unix_ping.rb', line 9

def send
  result = `ping -c 1 -W 5 #{host}`.match(/time=(\d+\.?\d*)/)
  self.duration = result[1].to_f / 1000 if result
  self
end