Method: App::UtilsTools.ping

Defined in:
lib/core/utils_tools.rb

.ping(host_address, verbose = true) ⇒ Object

Ping a URL or IP and returns the exit status. 0 = success, anything else means it failed.

Returns:

  • Integer



31
32
33
34
35
# File 'lib/core/utils_tools.rb', line 31

def self.ping(host_address, verbose = true)
    App::Terminal::output("Checking if #{App::Terminal::format_highlight(host_address)} is reachable...") if verbose == true
    `ping -t 1 -c 1 #{host_address}`
    $?.exitstatus
end