Sha256: ecfcf2a7427fc17d6327ff0a7c7ffa998e846bdead6dcbe0a43969037392e3c9

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8

#
#
#
class Comana::HostInspector::Ping
  PING_MIN_INTERVAL = 1

  #
  def initialize(hostname)
    @hostname = hostname
    @alive = ping
  end

  #Return true  if    ping respond from the host.
  #Return false if no ping respond from the host.
  def alive?
    @alive
  end

  private

  #Try ping three times.
  #Return true if at least one time responds.
  #def ping3
  def ping
    3.times do
      return true if system("ping -c 1 -W #{PING_MIN_INTERVAL} #{@hostname} 2> /dev/null 1> /dev/null")
    end
    return false
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comana-0.0.10 lib/comana/hostinspector/ping.rb