How to ping for reachability of remote host in Ruby
ruby
Solution
I use the `net-ping` gem which you need to install. Then the code is easy:
#!/usr/bin/env ruby
require 'net/ping'
def up?(host)
check = Net::Ping::External.new(host)
check.ping?
end
chost = '10.0.0.1'
puts up?(chost) # prints "true" if ping replies
Problem
I tried using ``` Ping.pingecho("10.102.52.42", 30) ``` for reachability of the remote host. This statement returns null even if I'm able to ping the IP manually. Is there an efficient way to determine the reachability of the remote machine in Ruby?