Module: Connectator::Pinger

Defined in:
lib/connectator/pinger.rb

Class Method Summary collapse

Class Method Details

.ping?(host, timeout = 1) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
# File 'lib/connectator/pinger.rb', line 3

def self.ping?(host, timeout = 1)
  Timeout::timeout(timeout) do
    `#{system_ping_command(host, timeout)}`
    ($?.exitstatus == 0)
  end
rescue Timeout::Error
  false
end